summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorExpressionLexer.cxx
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2014-02-08 17:01:30 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2014-02-21 21:56:06 (GMT)
commit68eb1757445dd1bb6537e32be8c9a72360112978 (patch)
tree52d0a4f39dd8c2f65b7f058120fab13858ed4284 /Source/cmGeneratorExpressionLexer.cxx
parent67253133f8ca99034a1eabe326a51c74f5e95c87 (diff)
downloadCMake-68eb1757445dd1bb6537e32be8c9a72360112978.zip
CMake-68eb1757445dd1bb6537e32be8c9a72360112978.tar.gz
CMake-68eb1757445dd1bb6537e32be8c9a72360112978.tar.bz2
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.
Diffstat (limited to 'Source/cmGeneratorExpressionLexer.cxx')
-rw-r--r--Source/cmGeneratorExpressionLexer.cxx70
1 files changed, 35 insertions, 35 deletions
diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx
index cd71ec0..117a24e 100644
--- a/Source/cmGeneratorExpressionLexer.cxx
+++ b/Source/cmGeneratorExpressionLexer.cxx
@@ -42,42 +42,42 @@ cmGeneratorExpressionLexer::Tokenize(const char *input)
const char *upto = c;
for ( ; *c; ++c)
- {
- if(c[0] == '$' && c[1] == '<')
{
- InsertText(upto, c, result);
- upto = c;
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::BeginExpression, upto, 2));
- upto = c + 2;
- ++c;
- SawBeginExpression = true;
- }
- else if(c[0] == '>')
- {
- InsertText(upto, c, result);
- upto = c;
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::EndExpression, upto, 1));
- upto = c + 1;
- SawGeneratorExpression = SawBeginExpression;
- }
- else if(c[0] == ':')
- {
- InsertText(upto, c, result);
- upto = c;
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::ColonSeparator, upto, 1));
- upto = c + 1;
- }
- else if(c[0] == ',')
- {
- InsertText(upto, c, result);
- upto = c;
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::CommaSeparator, upto, 1));
- upto = c + 1;
- }
+ switch(*c)
+ {
+ case '$':
+ if(c[1] == '<')
+ {
+ InsertText(upto, c, result);
+ result.push_back(cmGeneratorExpressionToken(
+ cmGeneratorExpressionToken::BeginExpression, c, 2));
+ upto = c + 2;
+ ++c;
+ SawBeginExpression = true;
+ }
+ break;
+ case '>':
+ InsertText(upto, c, result);
+ result.push_back(cmGeneratorExpressionToken(
+ cmGeneratorExpressionToken::EndExpression, c, 1));
+ upto = c + 1;
+ SawGeneratorExpression = SawBeginExpression;
+ break;
+ case ':':
+ InsertText(upto, c, result);
+ result.push_back(cmGeneratorExpressionToken(
+ cmGeneratorExpressionToken::ColonSeparator, c, 1));
+ upto = c + 1;
+ break;
+ case ',':
+ InsertText(upto, c, result);
+ result.push_back(cmGeneratorExpressionToken(
+ cmGeneratorExpressionToken::CommaSeparator, c, 1));
+ upto = c + 1;
+ break;
+ default:
+ break;
+ }
}
InsertText(upto, c, result);