diagnostics: Reduce cloning of DiagnosticEntry (#39193)

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-09-30 11:41:49 +00:00
committed by GitHub
parent d8cafdf937
commit 0811d48a7a
14 changed files with 172 additions and 93 deletions
+11 -14
View File
@@ -75,12 +75,9 @@ impl Render for ToolbarControls {
&ToggleDiagnosticsRefresh,
))
.on_click(cx.listener(move |toolbar_controls, _, _, cx| {
match toolbar_controls.editor() {
Some(editor) => {
editor.stop_updating(cx);
cx.notify();
}
None => {}
if let Some(editor) = toolbar_controls.editor() {
editor.stop_updating(cx);
cx.notify();
}
})),
)
@@ -95,11 +92,10 @@ impl Render for ToolbarControls {
&ToggleDiagnosticsRefresh,
))
.on_click(cx.listener({
move |toolbar_controls, _, window, cx| match toolbar_controls
.editor()
{
Some(editor) => editor.refresh_diagnostics(window, cx),
None => {}
move |toolbar_controls, _, window, cx| {
if let Some(editor) = toolbar_controls.editor() {
editor.refresh_diagnostics(window, cx)
}
}
})),
)
@@ -110,9 +106,10 @@ impl Render for ToolbarControls {
.icon_color(warning_color)
.shape(IconButtonShape::Square)
.tooltip(Tooltip::text(warning_tooltip))
.on_click(cx.listener(|this, _, window, cx| match &this.editor {
Some(editor) => editor.toggle_warnings(window, cx),
None => {}
.on_click(cx.listener(|this, _, window, cx| {
if let Some(editor) = &this.editor {
editor.toggle_warnings(window, cx)
}
})),
)
}