From 0a0974d0a80529be6cd236a7b679ce1a22269c5f Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Tue, 6 Mar 2018 09:50:23 -0500
Subject: [PATCH] SystemTools: Restore unconditional caching in
 GetActualCaseForPath

This reverts commit e9d2b696 (SystemTools: Cache only existing path
names in GetActualCaseForPath", 2017-11-07).  The lack of caching
introduced a big performance regression in CMake.  Another solution
for the original problem will be needed.
---
 SystemTools.cxx | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/SystemTools.cxx b/SystemTools.cxx
index 38910c8d..3e91a075 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -27,7 +27,6 @@
 #include <iostream>
 #include <set>
 #include <sstream>
-#include <utility>
 #include <vector>
 
 // Work-around CMake dependency scanning limitation.  This must
@@ -3342,7 +3341,7 @@ std::string SystemTools::RelativePath(const std::string& local,
 }
 
 #ifdef _WIN32
-static std::pair<std::string, bool> GetCasePathName(std::string const& pathIn)
+static std::string GetCasePathName(std::string const& pathIn)
 {
   std::string casePath;
   std::vector<std::string> path_components;
@@ -3351,7 +3350,7 @@ static std::pair<std::string, bool> GetCasePathName(std::string const& pathIn)
   {
     // Relative paths cannot be converted.
     casePath = pathIn;
-    return std::make_pair(casePath, false);
+    return casePath;
   }
 
   // Start with root component.
@@ -3403,7 +3402,7 @@ static std::pair<std::string, bool> GetCasePathName(std::string const& pathIn)
 
     casePath += path_components[idx];
   }
-  return std::make_pair(casePath, converting);
+  return casePath;
 }
 #endif
 
@@ -3418,14 +3417,12 @@ std::string SystemTools::GetActualCaseForPath(const std::string& p)
   if (i != SystemTools::PathCaseMap->end()) {
     return i->second;
   }
-  std::pair<std::string, bool> casePath = GetCasePathName(p);
-  if (casePath.first.size() > MAX_PATH) {
-    return casePath.first;
+  std::string casePath = GetCasePathName(p);
+  if (casePath.size() > MAX_PATH) {
+    return casePath;
   }
-  if (casePath.second) {
-    (*SystemTools::PathCaseMap)[p] = casePath.first;
-  }
-  return casePath.first;
+  (*SystemTools::PathCaseMap)[p] = casePath;
+  return casePath;
 #endif
 }
 
-- 
GitLab