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

Unified Diff: src/json-parser.h

Issue 974353002: Use faster IsDecimalDigit in the json parser (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
« 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: src/json-parser.h
diff --git a/src/json-parser.h b/src/json-parser.h
index bb743103b7bab558e53ec3f6fdfe6c2e18711b54..4cf52574b54655a9000651db6391f38bd9cf9450 100644
--- a/src/json-parser.h
+++ b/src/json-parser.h
@@ -314,7 +314,7 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
Advance();
uint32_t index = 0;
- if (c0_ >= '0' && c0_ <= '9') {
+ if (IsDecimalDigit(c0_)) {
// Maybe an array index, try to parse it.
if (c0_ == '0') {
// With a leading zero, the string has to be "0" only to be an index.
@@ -325,7 +325,7 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
if (index > 429496729U - ((d > 5) ? 1 : 0)) break;
index = (index * 10) + d;
Advance();
- } while (c0_ >= '0' && c0_ <= '9');
+ } while (IsDecimalDigit(c0_));
}
if (c0_ == '"') {
@@ -515,7 +515,7 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonNumber() {
Advance();
// Prefix zero is only allowed if it's the only digit before
// a decimal point or exponent.
- if ('0' <= c0_ && c0_ <= '9') return ReportUnexpectedCharacter();
+ if (IsDecimalDigit(c0_)) return ReportUnexpectedCharacter();
} else {
int i = 0;
int digits = 0;
@@ -524,7 +524,7 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonNumber() {
i = i * 10 + c0_ - '0';
digits++;
Advance();
- } while (c0_ >= '0' && c0_ <= '9');
+ } while (IsDecimalDigit(c0_));
if (c0_ != '.' && c0_ != 'e' && c0_ != 'E' && digits < 10) {
SkipWhitespace();
return Handle<Smi>(Smi::FromInt((negative ? -i : i)), isolate());
@@ -532,18 +532,18 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonNumber() {
}
if (c0_ == '.') {
Advance();
- if (c0_ < '0' || c0_ > '9') return ReportUnexpectedCharacter();
+ if (!IsDecimalDigit(c0_)) return ReportUnexpectedCharacter();
do {
Advance();
- } while (c0_ >= '0' && c0_ <= '9');
+ } while (IsDecimalDigit(c0_));
}
if (AsciiAlphaToLower(c0_) == 'e') {
Advance();
if (c0_ == '-' || c0_ == '+') Advance();
- if (c0_ < '0' || c0_ > '9') return ReportUnexpectedCharacter();
+ if (!IsDecimalDigit(c0_)) return ReportUnexpectedCharacter();
do {
Advance();
- } while (c0_ >= '0' && c0_ <= '9');
+ } while (IsDecimalDigit(c0_));
}
int length = position_ - beg_pos;
double number;
« 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