This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid some branches
authorKarl Williamson <khw@cpan.org>
Sat, 13 Jan 2018 22:40:34 +0000 (15:40 -0700)
committerKarl Williamson <khw@cpan.org>
Mon, 15 Jan 2018 22:20:47 +0000 (15:20 -0700)
commit1d2af5744d75143cf7ee8bfd33d4366a95dd1b95
treec84a30f7324a7318473554e3544a137a6b88ce7a
parent5d0379de16ad15d28efd4497c918e0ed272eb8c3
Avoid some branches

This replaces some looping with branchless code in two places: looking
for the first UTF-8 variant byte in a string (which is used under
several circumstances), and looking for an ASCII or non-ASCII character
during pattern matching.

Recent commits have changed these operations to do word-at-a-time look-
ups, essentially vectorizing the problem into 4 or 8 parallel probes.
But when the word is found which contains the desired byte, until this
commit, that word would be scanned byte-at-a-time in a loop.

I found some bit hacks on the internet, which when stitched togther, can
find the first desired byte in the word without branching, while doing
this while the word is still loaded, without having to load each byte.
embed.fnc
embed.h
ext/XS-APItest/APItest.pm
inline.h
proto.h
regexec.c