summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-01-06 18:49:41 -0700
committerKarl Williamson <khw@cpan.org>2020-01-13 20:58:56 -0700
commit35e5392d78ed72ffdbe2cd90bc35faf679493bea (patch)
treeb2e35598fb039daea68e8e7df38aad70e1f2174a /numeric.c
parentbcfb98ec0765d242dbd6338c36fb54cd40f6a9d9 (diff)
downloadperl-35e5392d78ed72ffdbe2cd90bc35faf679493bea.tar.gz
grok_bin_oct_hex(): Add branch prediction
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/numeric.c b/numeric.c
index d9e7b3581c..fe5e0f723b 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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