mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 22:21:15 -03: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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user