regcomp.c: _invlist_subtract() becomes a macro
authorKarl Williamson <public@khwilliamson.com>
Fri, 3 Feb 2012 17:57:33 +0000 (10:57 -0700)
committerKarl Williamson <public@khwilliamson.com>
Thu, 9 Feb 2012 17:13:54 +0000 (10:13 -0700)
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
embed.h
proto.h
regcomp.c
regexp.h

index 43aa54e..3ed6ac5 100644 (file)
--- 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 (file)
--- a/embed.h
+++ b/embed.h
 #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 (file)
--- 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)
index 3ae58bb..19ecee6 100644 (file)
--- 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 <result> to an inversion list which consists of all elements in
-     * <a> that aren't also in <b>.  *result should be defined upon input, and
-     * if it points to C<b> 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)
 {
index aefdac8..68d5830 100644 (file)
--- 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
 
 /*