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.
This commit is contained in:
Ben Boeckel
2018-01-23 19:31:17 -05:00
committed by Brad King
parent f2b8d67f19
commit 14a13d30ee

View File

@@ -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;