aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/Lexer.cpp
diff options
context:
space:
mode:
authorLeandro Melo <leandro.melo@nokia.com>2012-08-16 19:18:20 +0200
committerLeandro Melo <leandro.melo@nokia.com>2012-08-17 15:48:02 +0200
commitb9d15f12966a98c118ea3e747eb3c67920a5cfce (patch)
tree8eda7376712fc966113b557687499dcf6572cecb /src/libs/3rdparty/cplusplus/Lexer.cpp
parenta5900877495acaea30b885373e8e5540883fdebc (diff)
C++: Avoid looking ahead when lexing u8"literal"
This makes things slightly more efficient. But it will be more significant when we introduce R"rawliterals" since we would avoid an even further lookahead for cases like u8R"string". Change-Id: Id4bad8b917752d23daf2f4989330434979cf602f Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com> Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Lexer.cpp')
-rw-r--r--src/libs/3rdparty/cplusplus/Lexer.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/libs/3rdparty/cplusplus/Lexer.cpp b/src/libs/3rdparty/cplusplus/Lexer.cpp
index 5179d83b54..5214a345f7 100644
--- a/src/libs/3rdparty/cplusplus/Lexer.cpp
+++ b/src/libs/3rdparty/cplusplus/Lexer.cpp
@@ -580,19 +580,15 @@ void Lexer::scan_helper(Token *tok)
yyinp();
scanCharLiteral(tok, ch);
} else if (ch == 'u' && _yychar == '8') {
- unsigned char la = 0;
- if (_currentChar + 1 != _lastChar)
- la = *(_currentChar + 1);
- if (la == '"') {
- yyinp();
+ yyinp();
+ if (_yychar == '"') {
yyinp();
scanStringLiteral(tok, '8');
- } else if (la == '\'') {
- yyinp();
+ } else if (_yychar == '\'') {
yyinp();
scanCharLiteral(tok, '8');
} else {
- scanIdentifier(tok);
+ scanIdentifier(tok, 1);
}
} else {
scanIdentifier(tok);
@@ -691,9 +687,9 @@ void Lexer::scanNumericLiteral(Token *tok)
tok->number = control()->numericLiteral(yytext, yylen);
}
-void Lexer::scanIdentifier(Token *tok)
+void Lexer::scanIdentifier(Token *tok, unsigned extraProcessedChars)
{
- const char *yytext = _currentChar - 1;
+ const char *yytext = _currentChar - 1 - extraProcessedChars;
while (std::isalnum(_yychar) || _yychar == '_' || _yychar == '$')
yyinp();
int yylen = _currentChar - yytext;