[Lldb-commits] [PATCH] D80595: Also cache negative results in GetXcodeSDKPath (NFC)

Adrian Prantl via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue May 26 15:50:38 PDT 2020


aprantl created this revision.
aprantl added reviewers: JDevlieghere, friss.

This fixes a performance issue in the failure case.

      

rdar://63547920


https://reviews.llvm.org/D80595

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


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===================================================================
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -367,8 +367,10 @@
   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;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80595.266359.patch
Type: text/x-patch
Size: 659 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200526/ad78028c/attachment.bin>


More information about the lldb-commits mailing list