Skip to content

Commit 5765c81

Browse files
committed
Fixing number parsing of large ints
2 parents 92334a8 + c4218c8 commit 5765c81

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

include/simdjson/numberparsing.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,14 @@ static never_inline bool parse_large_integer(const uint8_t *const buf,
385385
#ifdef JSON_TEST_NUMBERS // for unit testing
386386
found_integer(signed_answer, buf + offset);
387387
#endif
388-
return is_structural_or_whitespace(*p);
389-
}
390-
int64_t signed_answer = -static_cast<int64_t>(i);
391-
pj.write_tape_s64(signed_answer);
388+
} else {
389+
// we can negate safely
390+
int64_t signed_answer = -static_cast<int64_t>(i);
391+
pj.write_tape_s64(signed_answer);
392392
#ifdef JSON_TEST_NUMBERS // for unit testing
393-
found_integer(signed_answer, buf + offset);
393+
found_integer(signed_answer, buf + offset);
394394
#endif
395-
return is_structural_or_whitespace(*p);
395+
}
396396
} else {
397397
// we have a positive integer, the contract is that
398398
// we try to represent it as a signed integer and only
@@ -408,8 +408,8 @@ static never_inline bool parse_large_integer(const uint8_t *const buf,
408408
#endif
409409
pj.write_tape_u64(i);
410410
}
411-
return is_structural_or_whitespace(*p);
412411
}
412+
return is_structural_or_whitespace(*p);
413413
}
414414

415415
// parse the number at buf + offset

0 commit comments

Comments
 (0)