regcomp.c: Add new static inline convenience function
authorKarl Williamson <khw@cpan.org>
Sat, 27 Feb 2016 20:54:51 +0000 (13:54 -0700)
committerKarl Williamson <khw@cpan.org>
Sun, 28 Feb 2016 01:08:36 +0000 (18:08 -0700)
embed.fnc
embed.h
proto.h
regcomp.c

index 4bd9e11..a08ebdc 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1532,6 +1532,7 @@ EiMn      |void   |invlist_set_previous_index|NN SV* const invlist|const IV index
 EiMRn  |IV     |invlist_previous_index|NN SV* const invlist
 EiMn   |void   |invlist_trim   |NN SV* invlist
 #endif
+EiM    |void   |invlist_clear  |NN SV* invlist
 EiMR   |SV*    |invlist_clone  |NN SV* const invlist
 EiMRn  |STRLEN*|get_invlist_iter_addr  |NN SV* invlist
 EiMn   |void   |invlist_iterinit|NN SV* invlist
diff --git a/embed.h b/embed.h
index 5d3f719..ede3520 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define handle_named_backref(a,b,c,d)  S_handle_named_backref(aTHX_ a,b,c,d)
 #define handle_possible_posix(a,b,c,d) S_handle_possible_posix(aTHX_ a,b,c,d)
 #define handle_regex_sets(a,b,c,d,e)   S_handle_regex_sets(aTHX_ a,b,c,d,e)
+#define invlist_clear(a)       S_invlist_clear(aTHX_ a)
 #define invlist_clone(a)       S_invlist_clone(aTHX_ a)
 #define invlist_contents(a,b)  S_invlist_contents(aTHX_ a,b)
 #define invlist_extend(a,b)    S_invlist_extend(aTHX_ a,b)
diff --git a/proto.h b/proto.h
index 2852f6f..0762b5c 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -4749,6 +4749,9 @@ STATIC int        S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state, const char*
 STATIC regnode*        S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV ** return_invlist, I32 *flagp, U32 depth, char * const oregcomp_parse);
 #define PERL_ARGS_ASSERT_HANDLE_REGEX_SETS     \
        assert(pRExC_state); assert(flagp); assert(oregcomp_parse)
+PERL_STATIC_INLINE void        S_invlist_clear(pTHX_ SV* invlist);
+#define PERL_ARGS_ASSERT_INVLIST_CLEAR \
+       assert(invlist)
 PERL_STATIC_INLINE SV* S_invlist_clone(pTHX_ SV* const invlist)
                        __attribute__warn_unused_result__;
 #define PERL_ARGS_ASSERT_INVLIST_CLONE \
index b5d4932..beff554 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -8442,6 +8442,17 @@ S_invlist_trim(SV* invlist)
     }
 }
 
+PERL_STATIC_INLINE void
+S_invlist_clear(pTHX_ SV* invlist)    /* Empty the inversion list */
+{
+    PERL_ARGS_ASSERT_INVLIST_CLEAR;
+
+    assert(SvTYPE(invlist) == SVt_INVLIST);
+
+    invlist_set_len(invlist, 0, 0);
+    invlist_trim(invlist);
+}
+
 #endif /* ifndef PERL_IN_XSUB_RE */
 
 PERL_STATIC_INLINE bool
@@ -9357,8 +9368,7 @@ Perl__invlist_intersection_maybe_complement_2nd(pTHX_ SV* const a, SV* const b,
                 invlist_replace_list_destroys_src(*i, r);
             }
             else {
-                invlist_set_len(*i, 0, 0);
-                invlist_trim(*i);
+                invlist_clear(*i);
             }
             SvREFCNT_dec_NN(r);
         }