From 6e6495664c54d7795d6cd7cbf193d558539241c5 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Thu, 16 Jan 2025 19:32:15 +0100 Subject: [PATCH] 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. --- src/exec.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/exec.rs b/src/exec.rs index a38407249..1161967a4 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -1106,7 +1106,6 @@ fn get_performer_for_builtin(p: &Process, j: &Job, io_chain: &IoChain) -> Box Box, 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 = - 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) }, )