replaceEnv(): Pass newEnv by reference

This commit is contained in:
Eelco Dolstra 2022-03-31 10:39:53 +02:00
parent 212623195c
commit 28309352d9

View file

@ -71,14 +71,12 @@ void clearEnv()
unsetenv(name.first.c_str()); unsetenv(name.first.c_str());
} }
void replaceEnv(std::map<std::string, std::string> newEnv) void replaceEnv(const std::map<std::string, std::string> & newEnv)
{ {
clearEnv(); clearEnv();
for (auto newEnvVar : newEnv) for (auto & newEnvVar : newEnv)
{
setenv(newEnvVar.first.c_str(), newEnvVar.second.c_str(), 1); setenv(newEnvVar.first.c_str(), newEnvVar.second.c_str(), 1);
} }
}
Path absPath(Path path, std::optional<PathView> dir, bool resolveSymlinks) Path absPath(Path path, std::optional<PathView> dir, bool resolveSymlinks)