Skip to content

Commit 3345521

Browse files
committed
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
1 parent c30c236 commit 3345521

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,10 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
367367
static std::mutex g_sdk_path_mutex;
368368

369369
std::lock_guard<std::mutex> guard(g_sdk_path_mutex);
370-
std::string &path = g_sdk_path[sdk.GetString()];
371-
if (path.empty())
372-
path = GetXcodeSDK(sdk);
370+
auto it = g_sdk_path.find(sdk.GetString());
371+
if (it != g_sdk_path.end())
372+
return it->second;
373+
std::string path = GetXcodeSDK(sdk);
374+
g_sdk_path.insert({sdk.GetString(), path});
373375
return path;
374376
}

0 commit comments

Comments
 (0)