summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-06-05 10:22:42 -0600
committerKarl Williamson <khw@cpan.org>2021-07-30 05:41:27 -0600
commitbf874180e9a7a8fbb74ab7eaa5c683ecc5a6ffc7 (patch)
treedcd3fbb669c5ffe256a551deac326fd1d66782df /regcomp.c
parent6e7a7813c390d2121876b9f8af4f37102e8d51fa (diff)
downloadperl-bf874180e9a7a8fbb74ab7eaa5c683ecc5a6ffc7.tar.gz
Create and use single_1bit_pos32()
This moves the code from regcomp.c to inline.h that calculates the position of the lone set bit in a U32. This is in preparation for use by other call sites.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/regcomp.c b/regcomp.c
index 8d3141fc90..62d3b466e2 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -19398,17 +19398,8 @@ S_optimize_regclass(pTHX_
bool already_inverted;
bool are_equivalent;
- /* Compute which bit is set, which is the same thing as, e.g.,
- * ANYOF_CNTRL. From
- * https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn
- * */
- static const int MultiplyDeBruijnBitPosition2[32] = {
- 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
- 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
- };
- namedclass = MultiplyDeBruijnBitPosition2[(posixl
- * 0x077CB531U) >> 27];
+ namedclass = single_1bit_pos32(posixl);
classnum = namedclass_to_classnum(namedclass);
/* The named classes are such that the inverted number is one