mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 10:51:15 -03:00
Optimize function calls by reducing inherit vars heap allocations and copies
* Convert `function_get_inherit_vars()` to return a reference to the (possibly) existing map, rather than a copy; * Preallocate and reuse a static (read-only) map for the (very) common case of no inherited vars; * Pass references to the inherit vars map around thereafter, never triggering the map copy (or even move) constructor. NB: If it turns out the reference is unsafe, we can switch the inherit vars to be a shared_ptr and return that instead.
This commit is contained in:
@@ -813,7 +813,7 @@ static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr<job_t>
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::map<wcstring, env_var_t> inherit_vars = function_get_inherit_vars(func_name);
|
||||
const std::map<wcstring, env_var_t> &inherit_vars = function_get_inherit_vars(func_name);
|
||||
|
||||
function_block_t *fb =
|
||||
parser.push_block<function_block_t>(p, func_name, props->shadow_scope);
|
||||
|
||||
Reference in New Issue
Block a user