@@ -517,20 +517,14 @@ bool Reader::decodeNumber(Token& token) {
517
517
}
518
518
519
519
bool Reader::decodeNumber (Token& token, Value& decoded) {
520
- bool isDouble = false ;
521
- for (Location inspect = token.start_ ; inspect != token.end_ ; ++inspect) {
522
- isDouble = isDouble || in (*inspect, ' .' , ' e' , ' E' , ' +' ) ||
523
- (*inspect == ' -' && inspect != token.start_ );
524
- }
525
- if (isDouble)
526
- return decodeDouble (token, decoded);
527
520
// Attempts to parse the number as an integer. If the number is
528
521
// larger than the maximum supported value of an integer then
529
522
// we decode the number as a double.
530
523
Location current = token.start_ ;
531
524
bool isNegative = *current == ' -' ;
532
525
if (isNegative)
533
526
++current;
527
+ // TODO: Help the compiler do the div and mod at compile time or get rid of them.
534
528
Value::LargestUInt maxIntegerValue =
535
529
isNegative ? Value::LargestUInt (-Value::minLargestInt)
536
530
: Value::maxLargestUInt;
@@ -539,9 +533,7 @@ bool Reader::decodeNumber(Token& token, Value& decoded) {
539
533
while (current < token.end_ ) {
540
534
Char c = *current++;
541
535
if (c < ' 0' || c > ' 9' )
542
- return addError (" '" + std::string (token.start_ , token.end_ ) +
543
- " ' is not a number." ,
544
- token);
536
+ return decodeDouble (token, decoded);
545
537
Value::UInt digit (c - ' 0' );
546
538
if (value >= threshold) {
547
539
// We've hit or exceeded the max value divided by 10 (rounded down). If
0 commit comments