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 authored and Brad King committed 2018-01-31 11:04:36 -05:00
1 parent f2b8d67f19
commit 14a13d30ee
1 file changed
+6
+6
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;