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

@@ -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
}
}