[Lldb-commits] [lldb] 3345521 - Also cache negative results in GetXcodeSDKPath (NFC)

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Wed May 27 12:26:15 PDT 2020


Author: Adrian Prantl
Date: 2020-05-27T12:26:04-07:00
New Revision: 334552150770faaa407fecab42f5333bb2a898a6

URL: https://github.com/llvm/llvm-project/commit/334552150770faaa407fecab42f5333bb2a898a6
DIFF: https://github.com/llvm/llvm-project/commit/334552150770faaa407fecab42f5333bb2a898a6.diff

LOG: 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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 79ccc5277d2e..cb6f03465ef7 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -367,8 +367,10 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
   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;
 }


        


More information about the lldb-commits mailing list