瀏覽代碼

cmGeneratorExpressionLexer: only tokenize strings with a '$'

In standard libraries, `std::string::find` is usually implemented using
vectorized code. Since the Tokenize method iterates
character-by-character, doing an initial check using `find` improves
performance.
Ben Boeckel 7 年之前
父節點
當前提交
14a13d30ee
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      Source/cmGeneratorExpressionLexer.cxx

+ 6 - 0
Source/cmGeneratorExpressionLexer.cxx

@@ -21,6 +21,12 @@ std::vector<cmGeneratorExpressionToken> cmGeneratorExpressionLexer::Tokenize(
 {
   std::vector<cmGeneratorExpressionToken> result;
 
+  if (input.find('$') == std::string::npos) {
+    result.push_back(cmGeneratorExpressionToken(
+      cmGeneratorExpressionToken::Text, input.c_str(), input.size()));
+    return result;
+  }
+
   const char* c = input.c_str();
   const char* upto = c;