Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1218)

Unified Diff: pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart

Issue 2711403002: Improve fasta scanner performance (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
index e1dd5f4d2eab75789939f0072a15dbe7e28f65c1..57f7b2af5183d4bc466c2500d97aff6c8287913b 100644
--- a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
@@ -231,165 +231,158 @@ abstract class AbstractScanner implements Scanner {
return next;
}
- if ($a <= next && next <= $z) {
+ int nextLower = next | 0x20;
+
+ if ($a <= nextLower && nextLower <= $z) {
if (identical($r, next)) {
return tokenizeRawStringKeywordOrIdentifier(next);
}
return tokenizeKeywordOrIdentifier(next, true);
}
- if (($A <= next && next <= $Z) ||
- identical(next, $_) ||
- identical(next, $$)) {
- return tokenizeKeywordOrIdentifier(next, true);
+ if (identical(next, $CLOSE_PAREN)) {
+ return appendEndGroup(CLOSE_PAREN_INFO, OPEN_PAREN_TOKEN);
}
- if (identical(next, $LT)) {
- return tokenizeLessThan(next);
+ if (identical(next, $OPEN_PAREN)) {
+ appendBeginGroup(OPEN_PAREN_INFO);
+ return advance();
}
- if (identical(next, $GT)) {
- return tokenizeGreaterThan(next);
+ if (identical(next, $SEMICOLON)) {
+ appendPrecedenceToken(SEMICOLON_INFO);
+ // Type parameters and arguments cannot contain semicolon.
+ discardOpenLt();
+ return advance();
}
- if (identical(next, $EQ)) {
- return tokenizeEquals(next);
+ if (identical(next, $PERIOD)) {
+ return tokenizeDotsOrNumber(next);
}
- if (identical(next, $BANG)) {
- return tokenizeExclamation(next);
+ if (identical(next, $COMMA)) {
+ appendPrecedenceToken(COMMA_INFO);
+ return advance();
}
- if (identical(next, $PLUS)) {
- return tokenizePlus(next);
+ if (identical(next, $EQ)) {
+ return tokenizeEquals(next);
}
- if (identical(next, $MINUS)) {
- return tokenizeMinus(next);
+ if (identical(next, $CLOSE_CURLY_BRACKET)) {
+ return appendEndGroup(CLOSE_CURLY_BRACKET_INFO, OPEN_CURLY_BRACKET_TOKEN);
}
- if (identical(next, $STAR)) {
- return tokenizeMultiply(next);
+ if (identical(next, $SLASH)) {
+ return tokenizeSlashOrComment(next);
}
- if (identical(next, $PERCENT)) {
- return tokenizePercent(next);
+
+ if (identical(next, $OPEN_CURLY_BRACKET)) {
+ appendBeginGroup(OPEN_CURLY_BRACKET_INFO);
+ return advance();
}
- if (identical(next, $AMPERSAND)) {
- return tokenizeAmpersand(next);
+ if (identical(next, $DQ) || identical(next, $SQ)) {
+ return tokenizeString(next, scanOffset, false);
}
- if (identical(next, $BAR)) {
- return tokenizeBar(next);
+ if(identical(next, $_)){
+ return tokenizeKeywordOrIdentifier(next, true);
}
- if (identical(next, $CARET)) {
- return tokenizeCaret(next);
+ if (identical(next, $COLON)) {
+ appendPrecedenceToken(COLON_INFO);
+ return advance();
}
- if (identical(next, $OPEN_SQUARE_BRACKET)) {
- return tokenizeOpenSquareBracket(next);
+ if (identical(next, $LT)) {
+ return tokenizeLessThan(next);
}
- if (identical(next, $TILDE)) {
- return tokenizeTilde(next);
+ if (identical(next, $GT)) {
+ return tokenizeGreaterThan(next);
}
- if (identical(next, $BACKSLASH)) {
- appendPrecedenceToken(BACKSLASH_INFO);
- return advance();
+ if (identical(next, $BANG)) {
+ return tokenizeExclamation(next);
}
- if (identical(next, $HASH)) {
- return tokenizeTag(next);
+ if (identical(next, $OPEN_SQUARE_BRACKET)) {
+ return tokenizeOpenSquareBracket(next);
}
- if (identical(next, $OPEN_PAREN)) {
- appendBeginGroup(OPEN_PAREN_INFO);
- return advance();
+ if (identical(next, $CLOSE_SQUARE_BRACKET)) {
+ return appendEndGroup(
+ CLOSE_SQUARE_BRACKET_INFO, OPEN_SQUARE_BRACKET_TOKEN);
}
- if (identical(next, $CLOSE_PAREN)) {
- return appendEndGroup(CLOSE_PAREN_INFO, OPEN_PAREN_TOKEN);
+ if (identical(next, $AT)) {
+ return tokenizeAt(next);
}
- if (identical(next, $COMMA)) {
- appendPrecedenceToken(COMMA_INFO);
- return advance();
+ if (next >= $1 && next <= $9) {
+ return tokenizeNumber(next);
}
- if (identical(next, $COLON)) {
- appendPrecedenceToken(COLON_INFO);
- return advance();
+ if (identical(next, $AMPERSAND)) {
+ return tokenizeAmpersand(next);
}
- if (identical(next, $SEMICOLON)) {
- appendPrecedenceToken(SEMICOLON_INFO);
- // Type parameters and arguments cannot contain semicolon.
- discardOpenLt();
- return advance();
+ if (identical(next, $0)) {
+ return tokenizeHexOrNumber(next);
}
if (identical(next, $QUESTION)) {
return tokenizeQuestion(next);
}
- if (identical(next, $CLOSE_SQUARE_BRACKET)) {
- return appendEndGroup(
- CLOSE_SQUARE_BRACKET_INFO, OPEN_SQUARE_BRACKET_TOKEN);
+ if (identical(next, $BAR)) {
+ return tokenizeBar(next);
}
- if (identical(next, $BACKPING)) {
- appendPrecedenceToken(BACKPING_INFO);
- return advance();
+ if (identical(next, $PLUS)) {
+ return tokenizePlus(next);
}
- if (identical(next, $OPEN_CURLY_BRACKET)) {
- appendBeginGroup(OPEN_CURLY_BRACKET_INFO);
- return advance();
+ if(identical(next, $$)){
+ return tokenizeKeywordOrIdentifier(next, true);
}
- if (identical(next, $CLOSE_CURLY_BRACKET)) {
- return appendEndGroup(CLOSE_CURLY_BRACKET_INFO, OPEN_CURLY_BRACKET_TOKEN);
+ if (identical(next, $MINUS)) {
+ return tokenizeMinus(next);
}
- if (identical(next, $SLASH)) {
- return tokenizeSlashOrComment(next);
+ if (identical(next, $STAR)) {
+ return tokenizeMultiply(next);
}
- if (identical(next, $AT)) {
- return tokenizeAt(next);
+ if (identical(next, $CARET)) {
+ return tokenizeCaret(next);
}
- if (identical(next, $DQ) || identical(next, $SQ)) {
- return tokenizeString(next, scanOffset, false);
+ if (identical(next, $TILDE)) {
+ return tokenizeTilde(next);
}
- if (identical(next, $PERIOD)) {
- return tokenizeDotsOrNumber(next);
+ if (identical(next, $PERCENT)) {
+ return tokenizePercent(next);
}
- if (identical(next, $0)) {
- return tokenizeHexOrNumber(next);
+ if (identical(next, $BACKPING)) {
+ appendPrecedenceToken(BACKPING_INFO);
+ return advance();
}
- // TODO(ahe): Would a range check be faster?
- if (identical(next, $1) ||
- identical(next, $2) ||
- identical(next, $3) ||
- identical(next, $4) ||
- identical(next, $5) ||
- identical(next, $6) ||
- identical(next, $7) ||
- identical(next, $8) ||
- identical(next, $9)) {
- return tokenizeNumber(next);
+ if (identical(next, $BACKSLASH)) {
+ appendPrecedenceToken(BACKSLASH_INFO);
+ return advance();
}
- if (identical(next, $EOF)) {
- return $EOF;
+ if (identical(next, $HASH)) {
+ return tokenizeTag(next);
}
+
if (next < 0x1f) {
return unexpected(next);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698