Browse Source

Merge topic 'fix-find-performane-regression'

bb3a348def find_package: Fix performance regression in 4.0.0 release

Acked-by: Kitware Robot <[email protected]>
Merge-request: !10731
Brad King 7 months ago
parent
commit
0556c1b455
1 changed files with 7 additions and 3 deletions
  1. 7 3
      Source/cmFindPackageCommand.cxx

+ 7 - 3
Source/cmFindPackageCommand.cxx

@@ -243,12 +243,14 @@ public:
       for (auto i = 0ul; i < directoryLister.GetNumberOfFiles(); ++i) {
         char const* const fname = directoryLister.GetFile(i);
         // Skip entries to ignore or that aren't directories.
-        if (isDirentryToIgnore(fname) || !directoryLister.FileIsDirectory(i)) {
+        if (isDirentryToIgnore(fname)) {
           continue;
         }
 
         if (!this->Names) {
-          this->Matches.emplace_back(fname);
+          if (directoryLister.FileIsDirectory(i)) {
+            this->Matches.emplace_back(fname);
+          }
         } else {
           for (auto const& n : *this->Names) {
             // NOTE Customization point for
@@ -261,7 +263,9 @@ public:
                   : cmsysString_strncasecmp(fname, name.c_str(),
                                             name.length())) == 0);
             if (equal) {
-              this->Matches.emplace_back(fname);
+              if (directoryLister.FileIsDirectory(i)) {
+                this->Matches.emplace_back(fname);
+              }
               break;
             }
           }