Config: Prevent duplicate lookup in EnvLoader::Load()

We can check the iterator itself instead of doing the lookup again.
This commit is contained in:
Lioncache committed 2025-10-09 14:56:57 -04:00
1 parent 3247e777c0
commit acdbbec78d
1 file changed
+4 -3
+4 -3
View File
@@ -283,9 +283,10 @@ void EnvLoader::Load() {
}
}
auto GetVar = [](EnvMapType& EnvMap, const std::string_view id) -> std::optional<std::string_view> {
if (EnvMap.find(id) != EnvMap.end()) {
return EnvMap.at(id);
auto GetVar = [](const EnvMapType& EnvMap, std::string_view id) -> std::optional<std::string_view> {
const auto EnvEntry = EnvMap.find(id);
if (EnvEntry != EnvMap.end()) {
return EnvEntry->second;
}
// If envp[] was empty, search using std::getenv()