on master help sign in
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.

commit85c23b31deb73d71bb38264485d728665f151d4a authorjeepee <jeepee@users.noreply.github.com> dateFri 1 Apr 2022, 15:16 (5 years ago) parent8165feb
1 file changed+2−5
helix-term/src/commands.rs+2−5
helix-term/src/commands.rs+2−5
@@ -1646,11 +1646,8 @@ fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Dir
16461646 wrap_around,
16471647 );
16481648 } else {
1649− // get around warning `mutable_borrow_reservation_conflict`
1650− // which will be a hard error in the future
1651− // see: https://github.com/rust-lang/rust/issues/59159
1652− let query = query.clone();
1653− cx.editor.set_error(format!("Invalid regex: {}", query));
1649+ let error = format!("Invalid regex: {}", query);
1650+ cx.editor.set_error(error);
16541651 }
16551652 }
16561653}