Use move semantics instead of swap in env_set

This commit backs out certain optimizations around setting environment
variables, and replaces them with move semantics. env_set accepts a
list,  by value, permitting callers to use std::move to transfer
ownership.
This commit is contained in:
ridiculousfish
2017-08-28 02:51:34 -07:00
parent 75dd852340
commit 4baada25b9
10 changed files with 59 additions and 119 deletions

View File

@@ -345,7 +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());
wcstring_list_t vals = it->second.as_const_list(); // we need a copy
wcstring_list_t vals = it->second.as_list(); // we need a copy
env_set(it->first, ENV_LOCAL | ENV_USER, vals); // because this mutates the list
}
}