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

Unified Diff: src/scanner.cc

Issue 974783003: Speed up parsing of smis (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ignore partially parsed octal-seeming decimal numbers 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
« no previous file with comments | « src/scanner.h ('k') | src/token.h » ('j') | 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 de1b8e8b7202d211b297e8ca5737fb8f411299ed..1d41cb59312039b22954a562d9328eddff6b75e6 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -913,6 +913,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) {
enum { DECIMAL, HEX, OCTAL, IMPLICIT_OCTAL, BINARY } kind = DECIMAL;
LiteralScope literal(this);
+ bool at_start = !seen_period;
if (seen_period) {
// we have already seen a decimal point of the float
AddLiteralChar('.');
@@ -962,6 +963,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) {
kind = IMPLICIT_OCTAL;
while (true) {
if (c0_ == '8' || c0_ == '9') {
+ at_start = false;
kind = DECIMAL;
break;
}
@@ -977,6 +979,21 @@ Token::Value Scanner::ScanNumber(bool seen_period) {
// Parse decimal digits and allow trailing fractional part.
if (kind == DECIMAL) {
+ if (at_start) {
+ int value = 0;
+ while (IsDecimalDigit(c0_)) {
+ value = 10 * value + (c0_ - '0');
+ AddLiteralCharAdvance();
+ }
+
+ if (next_.literal_chars->one_byte_literal().length() < 10 &&
+ c0_ != '.' && c0_ != 'e' && c0_ != 'E') {
+ smi_value_ = value;
+ literal.Complete();
+ return Token::SMI;
+ }
+ }
+
ScanDecimalDigits(); // optional
if (c0_ == '.') {
AddLiteralCharAdvance();
« no previous file with comments | « src/scanner.h ('k') | src/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698