Revert "Optimize function calls by reducing inherit vars heap allocations and copies"

This reverts commit cdce8511a1.

This change was unsafe. The prior version (now restored) took the lock and
then copied the data. By returning a reference, the caller holds a
reference to data outside of the lock.

This function isn't worth optimizing. Hardly any functions use this
facility, and for those that do, they typically just capture one or two
variables.
This commit is contained in:
ridiculousfish
2019-04-13 11:58:18 -07:00
parent cdce8511a1
commit 13c5f93d63
4 changed files with 5 additions and 7 deletions

View File

@@ -199,7 +199,7 @@ static wcstring functions_def(const wcstring &name) {
}
// Output any inherited variables as `set -l` lines.
const std::map<wcstring, env_var_t> &inherit_vars = function_get_inherit_vars(name);
std::map<wcstring, env_var_t> inherit_vars = function_get_inherit_vars(name);
for (const auto &kv : inherit_vars) {
wcstring_list_t lst;
kv.second.to_list(lst);