This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
handy.h: Convert XDIGIT_VALUE to branchless
authorKarl Williamson <khw@cpan.org>
Mon, 6 Jan 2020 22:22:29 +0000 (15:22 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 14 Jan 2020 03:57:47 +0000 (20:57 -0700)
commit1ce77b7dbf5a7c3e29830b4e99be0cb0d65645aa
tree7aac8af4d9663fa5aa21776fabc912bff49ca797
parent1ab100a8598da3fcda1b313c7a6415231a170eea
handy.h: Convert XDIGIT_VALUE to branchless

This removes a branch and an array lookup in the XDIGIT_VALUE() macro.
It adds some shifts, masks, and additions instead, though replacing a
mask and addition in the old way.

A somewhat more complicated version could be made for EBCDIC, but I'm
not bothering to do that, using an array lookup to convert the salient
value to ASCII, so on EBCDIC there isn't an array lookup removal.
handy.h