mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-15 22:44:01 +00:00
Avoid an errant copy in autoload_t::resolve_command
The ternary expression was causing the list of paths (e.g. $fish_function_path) to be copied. Avoid that copy with an if statement. This reduces the time spent in try_autoload from 2.4 sec to 961ms on the seq_echo benchmark run 1024 times, about 5% improvement. Oh, C++...
This commit is contained in:
parent
2cd336376e
commit
5bee1e3e1f
1 changed files with 5 additions and 2 deletions
|
@ -165,8 +165,11 @@ wcstring_list_t autoload_t::get_autoloaded_commands() const {
|
|||
}
|
||||
|
||||
maybe_t<wcstring> autoload_t::resolve_command(const wcstring &cmd, const environment_t &env) {
|
||||
maybe_t<env_var_t> mvar = env.get(env_var_name_);
|
||||
return resolve_command(cmd, mvar ? mvar->as_list() : wcstring_list_t{});
|
||||
if (maybe_t<env_var_t> mvar = env.get(env_var_name_)) {
|
||||
return resolve_command(cmd, mvar->as_list());
|
||||
} else {
|
||||
return resolve_command(cmd, wcstring_list_t{});
|
||||
}
|
||||
}
|
||||
|
||||
maybe_t<wcstring> autoload_t::resolve_command(const wcstring &cmd, const wcstring_list_t &paths) {
|
||||
|
|
Loading…
Reference in a new issue