summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorExpressionLexer.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2018-01-24 00:31:17 (GMT)
committerBrad King <brad.king@kitware.com>2018-01-31 16:04:36 (GMT)
commit14a13d30eefd657e56022d30d8976cfdfaf9ab06 (patch)
tree4397b35cf3eec381f6db81e828c8ac28d2a04537 /Source/cmGeneratorExpressionLexer.cxx
parentf2b8d67f1946bc59e95d1184f7ad64ac16193466 (diff)
downloadCMake-14a13d30eefd657e56022d30d8976cfdfaf9ab06.zip
CMake-14a13d30eefd657e56022d30d8976cfdfaf9ab06.tar.gz
CMake-14a13d30eefd657e56022d30d8976cfdfaf9ab06.tar.bz2
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.
Diffstat (limited to 'Source/cmGeneratorExpressionLexer.cxx')
-rw-r--r--Source/cmGeneratorExpressionLexer.cxx6
1 files changed, 6 insertions, 0 deletions
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<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;