Skip to content

Commit 88f287a

Browse files
committed
toke.c: scan_num: Use msbit_pos() to simplify code
A bunch of code here is replaced by this one call.
1 parent c2f9601 commit 88f287a

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

toke.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12488,8 +12488,6 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
1248812488
NV hexfp_nv = 0.0;
1248912489
#endif
1249012490
int hexfp_exp = 0;
12491-
UV high_non_zero = 0; /* highest digit */
12492-
int non_zero_integer_digits = 0;
1249312491
bool new_octal = FALSE; /* octal with "0o" prefix */
1249412492

1249512493
PERL_ARGS_ASSERT_SCAN_NUM;
@@ -12643,12 +12641,6 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
1264312641
n += (NV) b;
1264412642
}
1264512643

12646-
if (high_non_zero == 0 && b > 0)
12647-
high_non_zero = b;
12648-
12649-
if (high_non_zero)
12650-
non_zero_integer_digits++;
12651-
1265212644
/* this could be hexfp, but peek ahead
1265312645
* to avoid matching ".." */
1265412646
if (UNLIKELY(HEXFP_PEEK(s))) {
@@ -12674,23 +12666,12 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
1267412666
* detection will shortly be more thorough with the
1267512667
* underbar checks. */
1267612668
const char* h = s;
12677-
significant_bits = non_zero_integer_digits * shift;
12669+
significant_bits = (u == 0) ? 0 : msbit_pos(u) + 1;
1267812670
#ifdef HEXFP_UQUAD
1267912671
hexfp_uquad = u;
1268012672
#else /* HEXFP_NV */
1268112673
hexfp_nv = u;
1268212674
#endif
12683-
/* Ignore the leading zero bits of
12684-
* the high (first) non-zero digit. */
12685-
if (high_non_zero) {
12686-
if (high_non_zero < 0x8)
12687-
significant_bits--;
12688-
if (high_non_zero < 0x4)
12689-
significant_bits--;
12690-
if (high_non_zero < 0x2)
12691-
significant_bits--;
12692-
}
12693-
1269412675
if (*h == '.') {
1269512676
#ifdef HEXFP_NV
1269612677
NV nv_mult = 1.0;

0 commit comments

Comments
 (0)