diff options
author | Karl Williamson <khw@cpan.org> | 2020-01-06 18:49:41 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-01-13 20:58:56 -0700 |
commit | 35e5392d78ed72ffdbe2cd90bc35faf679493bea (patch) | |
tree | b2e35598fb039daea68e8e7df38aad70e1f2174a /numeric.c | |
parent | bcfb98ec0765d242dbd6338c36fb54cd40f6a9d9 (diff) | |
download | perl-35e5392d78ed72ffdbe2cd90bc35faf679493bea.tar.gz |
grok_bin_oct_hex(): Add branch prediction
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -335,10 +335,12 @@ Perl_grok_bin_oct_hex(pTHX_ const char *start, if (_generic_isCC(*s, class_bit)) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. - With gcc seems to be much straighter code than old scan_hex. */ + With gcc seems to be much straighter code than old scan_hex. + (khw suspects that adding a LIKELY() just above would do the + same thing) */ redo: if (!overflowed) { - if (value <= max_div) { + if (LIKELY(value <= max_div)) { value = (value << shift) | XDIGIT_VALUE(*s); /* Note XDIGIT_VALUE() is branchless, works on binary * and octal as well, so can be used here, without |