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:
Kurtis Rader
2017-08-19 15:45:46 -07:00
parent a77cd98136
commit 11400fb313
8 changed files with 112 additions and 113 deletions

View File

@@ -645,7 +645,8 @@ static void set_argparse_result_vars(argparse_cmd_opts_t &opts) {
if (!opt_spec->num_seen) continue;
if (opt_spec->short_flag_valid) {
env_set(var_name_prefix + opt_spec->short_flag, ENV_LOCAL, opt_spec->vals);
env_set(var_name_prefix + opt_spec->short_flag, ENV_LOCAL, opt_spec->vals,
opt_spec->long_flag.empty());
}
if (!opt_spec->long_flag.empty()) {
// We do a simple replacement of all non alphanum chars rather than calling