on master help sign in
dap: Avoid cloning old_breakpoints if we are immediately replacing them
9dd17c4Blaž Hrastnik
helix-term/src/commands/dap.rs+4−3
@@ -175,7 +175,7 @@ pub fn dap_start_impl(
175 }
175 }
176 };
176 };
177
177
178− let language_config = editor.syn_loader.language_config_for_file_name(&path);
178+ let language_config = editor.syn_loader.language_config_for_file_name(path);
179 let config = match language_config
179 let config = match language_config
180 .as_deref()
180 .as_deref()
181 .and_then(|config| config.debugger.as_ref())
181 .and_then(|config| config.debugger.as_ref())
@@ -216,6 +216,7 @@ pub fn dap_start_impl(
216
216
217 debugger.quirks = config.quirks.clone();
217 debugger.quirks = config.quirks.clone();
218
218
219+ // TODO: avoid refetching all of this... pass a config in
219 let start_config = match name {
220 let start_config = match name {
220 Some(name) => config.templates.iter().find(|t| t.name == name),
221 Some(name) => config.templates.iter().find(|t| t.name == name),
221 None => config.templates.get(0),
222 None => config.templates.get(0),
@@ -452,8 +453,8 @@ pub fn dap_toggle_breakpoint(cx: &mut Context) {
452 let request = debugger.set_breakpoints(path.clone(), breakpoints);
453 let request = debugger.set_breakpoints(path.clone(), breakpoints);
453 match block_on(request) {
454 match block_on(request) {
454 Ok(Some(breakpoints)) => {
455 Ok(Some(breakpoints)) => {
455− let old_breakpoints = debugger.breakpoints.clone();
456+ // TODO: avoid this clone here
456− debugger.breakpoints = breakpoints.clone();
457+ let old_breakpoints = std::mem::replace(&mut debugger.breakpoints, breakpoints.clone());
457 for bp in breakpoints {
458 for bp in breakpoints {
458 if !old_breakpoints.iter().any(|b| b.message == bp.message) {
459 if !old_breakpoints.iter().any(|b| b.message == bp.message) {
459 if let Some(msg) = &bp.message {
460 if let Some(msg) = &bp.message {