From d8feb0bcd19eb5da19dff34d89ca7a907beafd3f Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 1 Jan 2024 18:29:27 +0100 Subject: [PATCH] builtin bind: remove unused parameter This file uses the questionable "self.somemethod(self.somefield)" pattern. We should either set the functions free or stop passing redundant parameters. Not sure. For now fix one of them to avoid a string clone. --- fish-rust/src/builtins/bind.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/fish-rust/src/builtins/bind.rs b/fish-rust/src/builtins/bind.rs index 7ec28e8b1..69a6b3f27 100644 --- a/fish-rust/src/builtins/bind.rs +++ b/fish-rust/src/builtins/bind.rs @@ -254,9 +254,6 @@ fn add( /// an array of all key bindings to erase /// @param all /// if specified, _all_ key bindings will be erased - /// @param mode - /// if specified, only bindings from that mode will be erased. If not given - /// and @c all is @c false, @c DEFAULT_BIND_MODE will be used. /// @param use_terminfo /// Whether to look use terminfo -k name /// @@ -264,11 +261,16 @@ fn erase( &mut self, seq: &[&wstr], all: bool, - mode: Option<&wstr>, use_terminfo: bool, user: bool, streams: &mut IoStreams, ) -> bool { + let mode = if self.opts.bind_mode_given { + Some(self.opts.bind_mode.as_utfstr()) + } else { + None + }; + if all { self.input_mappings.clear(mode, user); return false; @@ -527,20 +529,11 @@ pub fn bind( match self.opts.mode { BIND_ERASE => { - // TODO: satisfy the borrow checker here. - let storage; - let bind_mode = if self.opts.bind_mode_given { - storage = self.opts.bind_mode.clone(); - Some(storage.as_utfstr()) - } else { - None - }; // If we get both, we erase both. if self.opts.user { if self.erase( &argv[optind..], self.opts.all, - bind_mode, self.opts.use_terminfo, true, /* user */ streams, @@ -552,7 +545,6 @@ pub fn bind( if self.erase( &argv[optind..], self.opts.all, - bind_mode, self.opts.use_terminfo, false, /* user */ streams,