cmGeneratorExpressionLexer: Use a switch statement to parse

Optimize cmGeneratorExpressionLexer::Tokenize to use a switch statement.
The many dereferences of the input pointer were expensive. Also remove
excess pointer arithmetic.
This commit is contained in:
Ben Boeckel 2014-02-08 12:01:30 -05:00 committed by Ben Boeckel
parent 67253133f8
commit 68eb175744
1 changed files with 35 additions and 35 deletions

View File

@ -43,40 +43,40 @@ cmGeneratorExpressionLexer::Tokenize(const char *input)
for ( ; *c; ++c)
{
if(c[0] == '$' && c[1] == '<')
switch(*c)
{
case '$':
if(c[1] == '<')
{
InsertText(upto, c, result);
upto = c;
result.push_back(cmGeneratorExpressionToken(
cmGeneratorExpressionToken::BeginExpression, upto, 2));
cmGeneratorExpressionToken::BeginExpression, c, 2));
upto = c + 2;
++c;
SawBeginExpression = true;
}
else if(c[0] == '>')
{
break;
case '>':
InsertText(upto, c, result);
upto = c;
result.push_back(cmGeneratorExpressionToken(
cmGeneratorExpressionToken::EndExpression, upto, 1));
cmGeneratorExpressionToken::EndExpression, c, 1));
upto = c + 1;
SawGeneratorExpression = SawBeginExpression;
}
else if(c[0] == ':')
{
break;
case ':':
InsertText(upto, c, result);
upto = c;
result.push_back(cmGeneratorExpressionToken(
cmGeneratorExpressionToken::ColonSeparator, upto, 1));
cmGeneratorExpressionToken::ColonSeparator, c, 1));
upto = c + 1;
}
else if(c[0] == ',')
{
break;
case ',':
InsertText(upto, c, result);
upto = c;
result.push_back(cmGeneratorExpressionToken(
cmGeneratorExpressionToken::CommaSeparator, upto, 1));
cmGeneratorExpressionToken::CommaSeparator, c, 1));
upto = c + 1;
break;
default:
break;
}
}
InsertText(upto, c, result);