[PATCH] D76097: improve performance of getSDKName()

Adrian Prantl via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 12 14:07:12 PDT 2020


aprantl created this revision.
aprantl added a reviewer: arphaman.
Herald added a subscriber: dexonsmith.

The ".sdk" component is usually the last one in the -isysroot, so it makes more sense to scan from the back. Also, technically, someone could install Xcode into a directory ending with .sdk, which would break this heuristic.


https://reviews.llvm.org/D76097

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1068,8 +1068,8 @@
 
 StringRef Darwin::getSDKName(StringRef isysroot) {
   // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk
-  auto BeginSDK = llvm::sys::path::begin(isysroot);
-  auto EndSDK = llvm::sys::path::end(isysroot);
+  auto BeginSDK = llvm::sys::path::rbegin(isysroot);
+  auto EndSDK = llvm::sys::path::rend(isysroot);
   for (auto IT = BeginSDK; IT != EndSDK; ++IT) {
     StringRef SDK = *IT;
     if (SDK.endswith(".sdk"))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76097.250047.patch
Type: text/x-patch
Size: 649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200312/424ef9e1/attachment.bin>


More information about the cfe-commits mailing list