From 14a13d30eefd657e56022d30d8976cfdfaf9ab06 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 23 Jan 2018 19:31:17 -0500 Subject: 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. --- Source/cmGeneratorExpressionLexer.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx index 95c79c1..e37f165 100644 --- a/Source/cmGeneratorExpressionLexer.cxx +++ b/Source/cmGeneratorExpressionLexer.cxx @@ -21,6 +21,12 @@ std::vector cmGeneratorExpressionLexer::Tokenize( { std::vector 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; -- cgit v0.12