From 85c23b31deb73d71bb38264485d728665f151d4a Mon Sep 17 00:00:00 2001 From: jeepee Date: Fri, 1 Apr 2022 15:16:51 +0200 Subject: [PATCH] Avoid unnecessary clone when formatting error (#1903) Instead of first cloning the query and then allocating again to format the error, format the error using a reference to the query. --- helix-term/src/commands.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index f4844170a..296480395 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1646,11 +1646,8 @@ fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Dir wrap_around, ); } else { - // get around warning `mutable_borrow_reservation_conflict` - // which will be a hard error in the future - // see: https://github.com/rust-lang/rust/issues/59159 - let query = query.clone(); - cx.editor.set_error(format!("Invalid regex: {}", query)); + let error = format!("Invalid regex: {}", query); + cx.editor.set_error(error); } } }