mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 21:21:15 -03:00
Make history::remove take a &wstr instead of a WString
While it does need to store the string, we also need to use the string after storing it, so we aren't getting any advantage from passing by value. Just pass by reference to simplify the call sites.
This commit is contained in:
@@ -307,8 +307,8 @@ pub fn history(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) ->
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
for &delete_string in args {
|
||||
history.remove(delete_string.to_owned());
|
||||
for delete_string in args {
|
||||
history.remove(delete_string);
|
||||
}
|
||||
}
|
||||
HistCmd::HIST_CLEAR => {
|
||||
|
||||
@@ -1015,9 +1015,9 @@ fn is_empty(&mut self) -> bool {
|
||||
}
|
||||
|
||||
/// Remove a history item.
|
||||
fn remove(&mut self, str_to_remove: WString) {
|
||||
fn remove(&mut self, str_to_remove: &wstr) {
|
||||
// Add to our list of deleted items.
|
||||
self.deleted_items.insert(str_to_remove.clone(), false);
|
||||
self.deleted_items.insert(str_to_remove.to_owned(), false);
|
||||
|
||||
for idx in (0..self.new_items.len()).rev() {
|
||||
let matched = self.new_items[idx].str() == str_to_remove;
|
||||
@@ -1528,7 +1528,7 @@ pub fn is_empty(&self) -> bool {
|
||||
}
|
||||
|
||||
/// Remove a history item.
|
||||
pub fn remove(&self, s: WString) {
|
||||
pub fn remove(&self, s: &wstr) {
|
||||
self.imp().remove(s)
|
||||
}
|
||||
|
||||
|
||||
@@ -2566,8 +2566,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
|
||||
rl::HistoryPagerDelete => {
|
||||
// Also applies to ordinary history search.
|
||||
if !self.history_search.is_at_end() {
|
||||
self.history
|
||||
.remove(self.history_search.current_result().to_owned());
|
||||
self.history.remove(self.history_search.current_result());
|
||||
self.history.save();
|
||||
self.history_search.handle_deletion();
|
||||
self.update_command_line_from_history_search();
|
||||
@@ -2582,7 +2581,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
|
||||
if let Some(completion) =
|
||||
self.pager.selected_completion(&self.current_page_rendering)
|
||||
{
|
||||
self.history.remove(completion.completion.clone());
|
||||
self.history.remove(&completion.completion);
|
||||
self.history.save();
|
||||
self.fill_history_pager(
|
||||
HistoryPagerInvocation::Refresh,
|
||||
|
||||
@@ -147,7 +147,7 @@ macro_rules! test_history_matches {
|
||||
// Test item removal case-sensitive.
|
||||
let mut searcher = HistorySearch::new(history.clone(), L!("Alpha").to_owned());
|
||||
test_history_matches!(searcher, vec![L!("Alpha")]);
|
||||
history.remove(L!("Alpha").to_owned());
|
||||
history.remove(L!("Alpha"));
|
||||
let mut searcher = HistorySearch::new(history.clone(), L!("Alpha").to_owned());
|
||||
test_history_matches!(searcher, vec![]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user