Bläddra i källkod

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 år sedan
förälder
incheckning
14a13d30ee
1 ändrade filer med 6 tillägg och 0 borttagningar
  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;