mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-14 06:22:51 +08:00
Don't clone argv for builtins
We capture the process already, and we use argv by reference for the other cases. argv can be big, and this reduces allocations and thereby memory usage and speed. E.g. `set -l foo **` with 200k matches has 25% reduced memory usage and ~5% reduced runtime.
This commit is contained in:
parent
ced5569a25
commit
6e6495664c
|
@ -1106,7 +1106,6 @@ fn get_performer_for_builtin(p: &Process, j: &Job, io_chain: &IoChain) -> Box<Pr
|
|||
|
||||
// Pull out some fields which we want to copy. We don't want to store the process or job in the
|
||||
// returned closure.
|
||||
let argv = p.argv().clone();
|
||||
let job_group = j.group.clone();
|
||||
let io_chain = io_chain.clone();
|
||||
|
||||
|
@ -1114,7 +1113,7 @@ fn get_performer_for_builtin(p: &Process, j: &Job, io_chain: &IoChain) -> Box<Pr
|
|||
// thread.
|
||||
Box::new(
|
||||
move |parser: &Parser,
|
||||
_p: &Process,
|
||||
p: &Process,
|
||||
output_stream: Option<&mut OutputStream>,
|
||||
errput_stream: Option<&mut OutputStream>| {
|
||||
let output_stream = output_stream.unwrap();
|
||||
|
@ -1152,7 +1151,7 @@ fn get_performer_for_builtin(p: &Process, j: &Job, io_chain: &IoChain) -> Box<Pr
|
|||
|
||||
// Execute the builtin.
|
||||
let mut shim_argv: Vec<&wstr> =
|
||||
argv.iter().map(|s| truncate_at_nul(s.as_ref())).collect();
|
||||
p.argv().iter().map(|s| truncate_at_nul(s.as_ref())).collect();
|
||||
builtin_run(parser, &mut shim_argv, &mut streams)
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user