From 3f80b5713f755394d2d1a3bc3befb0dd82a19f64 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Fri, 3 Feb 2012 10:57:33 -0700 Subject: [PATCH] regcomp.c: _invlist_subtract() becomes a macro This function is no longer necessary, as it is just a call to the newly created _invlist_intersection_maybe_complement_2nd() with the correct parameters. --- embed.fnc | 2 +- embed.h | 1 - proto.h | 6 ++---- regcomp.c | 40 ---------------------------------------- regexp.h | 4 ++++ 5 files changed, 7 insertions(+), 46 deletions(-) diff --git a/embed.fnc b/embed.fnc index 43aa54e..3ed6ac5 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1379,7 +1379,7 @@ EsMR |IV |invlist_search |NN SV* const invlist|const UV cp EXmM |void |_invlist_intersection |NN SV* const a|NN SV* const b|NN SV** i EXpM |void |_invlist_intersection_maybe_complement_2nd|NULLOK SV* const a|NN SV* const b|bool complement_b|NN SV** i EXpM |void |_invlist_union |NULLOK SV* const a|NN SV* const b|NN SV** output -EXpM |void |_invlist_subtract|NN SV* const a|NN SV* const b|NN SV** result +EXmM |void |_invlist_subtract|NN SV* const a|NN SV* const b|NN SV** result EXpM |void |_invlist_invert|NN SV* const invlist EXpM |void |_invlist_invert_prop|NN SV* const invlist EXMpR |HV* |_swash_inversion_hash |NN SV* const swash diff --git a/embed.h b/embed.h index 66dfe9a..7d4313f 100644 --- a/embed.h +++ b/embed.h @@ -953,7 +953,6 @@ #define _invlist_invert(a) Perl__invlist_invert(aTHX_ a) #define _invlist_invert_prop(a) Perl__invlist_invert_prop(aTHX_ a) #define _invlist_populate_swatch(a,b,c,d) Perl__invlist_populate_swatch(aTHX_ a,b,c,d) -#define _invlist_subtract(a,b,c) Perl__invlist_subtract(aTHX_ a,b,c) #define _invlist_union(a,b,c) Perl__invlist_union(aTHX_ a,b,c) #define _new_invlist(a) Perl__new_invlist(aTHX_ a) #define _swash_inversion_hash(a) Perl__swash_inversion_hash(aTHX_ a) diff --git a/proto.h b/proto.h index 9e114c2..c79be42 100644 --- a/proto.h +++ b/proto.h @@ -6577,12 +6577,10 @@ PERL_CALLCONV void Perl__invlist_populate_swatch(pTHX_ SV* const invlist, const #define PERL_ARGS_ASSERT__INVLIST_POPULATE_SWATCH \ assert(invlist); assert(swatch) -PERL_CALLCONV void Perl__invlist_subtract(pTHX_ SV* const a, SV* const b, SV** result) +/* PERL_CALLCONV void _invlist_subtract(pTHX_ SV* const a, SV* const b, SV** result) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2) - __attribute__nonnull__(pTHX_3); -#define PERL_ARGS_ASSERT__INVLIST_SUBTRACT \ - assert(a); assert(b); assert(result) + __attribute__nonnull__(pTHX_3); */ PERL_CALLCONV void Perl__invlist_union(pTHX_ SV* const a, SV* const b, SV** output) __attribute__nonnull__(pTHX_2) diff --git a/regcomp.c b/regcomp.c index 3ae58bb..19ecee6 100644 --- a/regcomp.c +++ b/regcomp.c @@ -7087,46 +7087,6 @@ S_invlist_clone(pTHX_ SV* const invlist) return new_invlist; } -#ifndef PERL_IN_XSUB_RE -void -Perl__invlist_subtract(pTHX_ SV* const a, SV* const b, SV** result) -{ - /* Point to an inversion list which consists of all elements in - * that aren't also in . *result should be defined upon input, and - * if it points to C its reference count will be decremented. */ - - PERL_ARGS_ASSERT__INVLIST_SUBTRACT; - assert(a != b); - - /* Subtracting nothing retains the original */ - if (invlist_len(b) == 0) { - - if (*result == b) { - SvREFCNT_dec(b); - } - - /* If the result is not to be the same variable as the original, create - * a copy */ - if (*result != a) { - *result = invlist_clone(a); - } - } else { - SV *b_copy = invlist_clone(b); - _invlist_invert(b_copy); /* Everything not in 'b' */ - - if (*result == b) { - SvREFCNT_dec(b); - } - - _invlist_intersection(a, b_copy, result); /* Everything in 'a' not in - 'b' */ - SvREFCNT_dec(b_copy); - } - - return; -} -#endif - PERL_STATIC_INLINE UV* S_get_invlist_iter_addr(pTHX_ SV* invlist) { diff --git a/regexp.h b/regexp.h index aefdac8..68d5830 100644 --- a/regexp.h +++ b/regexp.h @@ -57,6 +57,10 @@ typedef struct regexp_paren_pair { #if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C) #define _invlist_intersection(a, b, output) _invlist_intersection_maybe_complement_2nd(a, b, FALSE, output) + +/* Subtracting b from a leaves in a everything that was there that isn't in b, + * that is the intersection of a with b's complement */ +#define _invlist_subtract(a, b, output) _invlist_intersection_maybe_complement_2nd(a, b, TRUE, output) #endif /* -- 2.7.4