]> Codestin Search App

Thanks to visit codestin.com
Credit goes to perl5.git.perl.org

This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
grok_bin_oct_hex: Shortcut leading zeros
authorKarl Williamson <[email protected]>
Wed, 5 Nov 2025 13:34:19 +0000 (06:34 -0700)
committerKarl Williamson <[email protected]>
Wed, 12 Nov 2025 21:05:11 +0000 (14:05 -0700)
commitbf4a950e7992432fc85bce07e901b7e3a0cc1355
treef9d3bc6ce22971eb34f87b2d2a87f8f7009142ca
parentdf1cfef7b22a161bc54afb2ae0ac65a96905986f
grok_bin_oct_hex: Shortcut leading zeros

I noticed that leading zeros are quite common for octal and hex
constants.  This code is structured for speed, with a partially unrolled
loop structured so that it is impossible to overflow the unrolled part.

If we get to the end of the unrolled portion, and the accumulated value
is still zero, it's because there have been only leading zeroes so far,
and instead of dropping into the loop, we can re-enter the unrolled part
without having to consider the possibility of overflowing.  This allows
the next chunk of digits to be processed without branching.
numeric.c