Skip to content

Commit

Permalink
Faster float handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ohler55 committed Jul 1, 2020
1 parent 6d99640 commit e8c241d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions ext/oj/sparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ read_num(ParseInfo pi) {
ni.neg = 0;
ni.hasExp = 0;
ni.no_big = (FloatDec == pi->options.bigdec_load);

c = reader_get(&pi->rd);
if ('-' == c) {
c = reader_get(&pi->rd);
Expand Down Expand Up @@ -469,11 +470,19 @@ read_num(ParseInfo pi) {
if (0 < ni.num || 0 < ni.i) {
dec_cnt++;
}
ni.num = ni.num * 10 + d;
ni.div *= 10;
ni.di++;
if (INT64_MAX <= ni.div || DEC_MAX < dec_cnt) {
ni.big = 1;
if (INT64_MAX <= ni.div) {
if (!ni.no_big) {
ni.big = true;
}
} else {
ni.num = ni.num * 10 + d;
ni.div *= 10;
ni.di++;
if (INT64_MAX <= ni.div || DEC_MAX < dec_cnt) {
if (!ni.no_big) {
ni.big = true;
}
}
}
}
}
Expand Down

0 comments on commit e8c241d

Please sign in to comment.