Also cache negative results in GetXcodeSDKPath (NFC)

This fixes a performance issue in the failure case.

rdar://63547920

Differential Revision: https://reviews.llvm.org/D80595
This commit is contained in:
Adrian Prantl 2020-05-26 15:40:43 -07:00
parent c30c2368c7
commit 3345521507
1 changed files with 5 additions and 3 deletions

View File

@ -367,8 +367,10 @@ llvm::StringRef HostInfoMacOSX::GetXcodeSDKPath(XcodeSDK sdk) {
static std::mutex g_sdk_path_mutex;
std::lock_guard<std::mutex> guard(g_sdk_path_mutex);
std::string &path = g_sdk_path[sdk.GetString()];
if (path.empty())
path = GetXcodeSDK(sdk);
auto it = g_sdk_path.find(sdk.GetString());
if (it != g_sdk_path.end())
return it->second;
std::string path = GetXcodeSDK(sdk);
g_sdk_path.insert({sdk.GetString(), path});
return path;
}