Skip to content

Commit

Permalink
Avoid unnecessary clone when formatting error (#1903)
Browse files Browse the repository at this point in the history
Instead of first cloning the query and then allocating again to format
the error, format the error using a reference to the query.
  • Loading branch information
jeepee authored Apr 1, 2022
1 parent 8165feb commit 85c23b3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 85c23b3

Please sign in to comment.