瀏覽代碼

ENH: speed up for NOTFOUND

Bill Hoffman 21 年之前
父節點
當前提交
f49e76899c
共有 1 個文件被更改,包括 10 次插入4 次删除
  1. 10 4
      Source/cmSystemTools.cxx

+ 10 - 4
Source/cmSystemTools.cxx

@@ -304,12 +304,18 @@ bool cmSystemTools::IsOn(const char* val)
 
 
 bool cmSystemTools::IsNOTFOUND(const char* val)
 bool cmSystemTools::IsNOTFOUND(const char* val)
 {
 {
-  cmsys::RegularExpression reg("-NOTFOUND$");
-  if(reg.find(val))
+  int len = strlen(val);
+  const char* notfound = "-NOTFOUND";
+  const int lenNotFound = 9;
+  if(len < lenNotFound-1)
     {
     {
-    return true;
+    return false;
+    }
+  if(len == lenNotFound-1)
+    {
+    return ( strcmp(val, "NOTFOUND") == 0);
     }
     }
-  return std::string("NOTFOUND") == val;
+  return ((strncmp((val + (len - lenNotFound)), notfound, lenNotFound) == 0));
 }
 }