basenc: fix unlikely locale issue; tune
commit60bd7bad9d2473d2bd0462a1cbe05144c35ad557
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 25 Oct 2023 22:09:04 +0000 (25 15:09 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 25 Oct 2023 22:09:27 +0000 (25 15:09 -0700)
treedd038ce37a392edf264ac66f55f6c4cd4a5cee5a
parentdcc1514d9ac12a98bf3067c206ce8e756c604719
basenc: fix unlikely locale issue; tune

This sped up ‘basenc -d --base16’ by 60% on my old platform,
AMD Phenom II X4 910e, Fedora 38.
* src/basenc.c (struct base16_decode_context): Simplify by
omitting have_nibble.  ‘nibble’ is now negative if it’s missing.
All uses changed.
(B16): New macro, inspired by ../lib/base64.c.
(base16_to_int): New static var, likewise.
(isubase16): Reimplement using base16_to_int, since isxdigit is
not guaranteed to succeed on the chars we want when the locale is
oddball.
(base16_decode_ctx): Tune by using base16_to_int and by
src/basenc.c