Browse Source

PERF: micro optimization: the (*pos1) && (*pos1=='/') were redundant, and
hasDoubleSlash is false in most cases, so in most cases 3 comparisons were
done, now only one

Alex

Alexander Neundorf 18 years ago
parent
commit
dddbad259c
2 changed files with 4 additions and 7 deletions
  1. 3 5
      Source/cmLocalGenerator.cxx
  2. 1 2
      Source/kwsys/SystemTools.cxx

+ 3 - 5
Source/cmLocalGenerator.cxx

@@ -2193,13 +2193,12 @@ std::string cmLocalGenerator::Convert(const char* source,
         break;
         break;
       }
       }
     }
     }
-  
   // Now convert it to an output path.
   // Now convert it to an output path.
   if (output == MAKEFILE)
   if (output == MAKEFILE)
     {
     {
     result = cmSystemTools::ConvertToOutputPath(result.c_str());
     result = cmSystemTools::ConvertToOutputPath(result.c_str());
     }
     }
-  if( output == SHELL)
+  else if( output == SHELL)
     {
     {
         // For the MSYS shell convert drive letters to posix paths, so
         // For the MSYS shell convert drive letters to posix paths, so
     // that c:/some/path becomes /c/some/path.  This is needed to
     // that c:/some/path becomes /c/some/path.  This is needed to
@@ -2298,9 +2297,8 @@ static bool cmLocalGeneratorNotAbove(const char* a, const char* b)
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 std::string
 std::string
-cmLocalGenerator
-::ConvertToRelativePath(const std::vector<std::string>& local,
-                        const char* in_remote)
+cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
+                                        const char* in_remote)
 {
 {
   // The path should never be quoted.
   // The path should never be quoted.
   assert(in_remote[0] != '\"');
   assert(in_remote[0] != '\"');

+ 1 - 2
Source/kwsys/SystemTools.cxx

@@ -1344,8 +1344,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
       }
       }
 
 
     // Also, reuse the loop to check for slash followed by another slash
     // Also, reuse the loop to check for slash followed by another slash
-    if ( !hasDoubleSlash && *pos1 &&
-      *pos1 == '/' && *(pos1+1) == '/' )
+    if (*pos1 == '/' && *(pos1+1) == '/' && !hasDoubleSlash)
       {
       {
 #ifdef _WIN32
 #ifdef _WIN32
       // However, on windows if the first characters are both slashes,
       // However, on windows if the first characters are both slashes,