mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-17 19:21:15 -03:00
Another fish var performance improvement
Make setting fish vars more efficient by avoiding creating a wcstring_list_t for the case where we're setting one value. For the case where we're passing a list of values swap it with the list in the var rather than copying it. This makes the benchmark in #4200 approximately 6% faster.
This commit is contained in:
@@ -345,6 +345,7 @@ void function_prepare_environment(const wcstring &name, const wchar_t *const *ar
|
||||
// It should be impossible for the var to be missing since we're inheriting it from an outer
|
||||
// scope. So we now die horribly if it is missing.
|
||||
assert(!it->second.missing());
|
||||
env_set(it->first, ENV_LOCAL | ENV_USER, it->second.as_const_list());
|
||||
wcstring_list_t vals = it->second.as_const_list(); // we need a copy
|
||||
env_set(it->first, ENV_LOCAL | ENV_USER, vals); // because this mutates the list
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user