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

Unified Diff: src/scanner.cc

Issue 975043002: Speed up string scanning (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« src/scanner.h ('K') | « src/scanner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.cc
diff --git a/src/scanner.cc b/src/scanner.cc
index a141f8aa0208a9144a0732071a6db307c621a5cd..e5dd0b9c4f4b334e436049691621b4d57e8ac428 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -790,9 +790,26 @@ uc32 Scanner::ScanOctalEscape(uc32 c, int length) {
Token::Value Scanner::ScanString() {
uc32 quote = c0_;
- Advance(); // consume quote
+ Advance<false, false>(); // consume quote
LiteralScope literal(this);
+ while (true) {
+ if (c0_ > 127) {
marja 2015/03/04 08:52:51 I was briefly confused by the 127. Why so restrict
+ HandleLeadSurrogate();
+ break;
+ }
+ if (c0_ < 0 || c0_ == '\n' || c0_ == '\r') return Token::ILLEGAL;
+ if (c0_ == quote) {
+ literal.Complete();
+ Advance<false, false>();
+ return Token::STRING;
+ }
+ uc32 c = c0_;
+ if (c == '\\') break;
+ Advance<false, false>();
+ AddLiteralChar(c);
+ }
+
while (c0_ != quote && c0_ >= 0
&& !unicode_cache_->IsLineTerminator(c0_)) {
uc32 c = c0_;
@@ -993,11 +1010,11 @@ Token::Value Scanner::ScanNumber(bool seen_period) {
c0_ != '.' && c0_ != 'e' && c0_ != 'E') {
smi_value_ = value;
literal.Complete();
- HandleLeadSurrugate();
+ HandleLeadSurrogate();
return Token::SMI;
}
- HandleLeadSurrugate();
+ HandleLeadSurrogate();
}
ScanDecimalDigits(); // optional
@@ -1230,7 +1247,7 @@ Token::Value Scanner::ScanIdentifierOrKeyword() {
harmony_classes_);
}
- HandleLeadSurrugate();
+ HandleLeadSurrogate();
} else if (IsInRange(c0_, 'A', 'Z') || c0_ == '_' || c0_ == '$') {
do {
uc32 first_char = c0_;
@@ -1243,7 +1260,7 @@ Token::Value Scanner::ScanIdentifierOrKeyword() {
return Token::IDENTIFIER;
}
- HandleLeadSurrugate();
+ HandleLeadSurrogate();
} else if (c0_ == '\\') {
// Scan identifier start character.
uc32 c = ScanIdentifierUnicodeEscape();
« src/scanner.h ('K') | « src/scanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698