diff options
author | Karl Williamson <public@khwilliamson.com> | 2012-02-03 15:08:10 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2012-02-09 10:13:55 -0700 |
commit | 8dc9348a4fe3df8461968371e8024a3b4842cc16 (patch) | |
tree | 01faef8c99fd494f4ba33edc51efb058d777b7e9 /regcomp.c | |
parent | 164173a25b2f985f00a4cb2ce75ac3918aef2e02 (diff) | |
download | perl-8dc9348a4fe3df8461968371e8024a3b4842cc16.tar.gz |
regcomp.c: Use new complement union
Previous commits have changed the API of invlist_union so the first
parameter can be NULL, and are to take the complement of the 2nd. We
can take advantage of that to simplify this code.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 16 |
1 files changed, 4 insertions, 12 deletions
@@ -6330,6 +6330,8 @@ S_invlist_trim(pTHX_ SV* const invlist) #define ELEMENT_RANGE_MATCHES_INVLIST(i) (! ((i) & 1)) #define PREV_RANGE_MATCHES_INVLIST(i) (! ELEMENT_RANGE_MATCHES_INVLIST(i)) +#define _invlist_union_complement_2nd(a, b, output) _invlist_union_maybe_complement_2nd(a, b, TRUE, output) + #ifndef PERL_IN_XSUB_RE void Perl__append_range_to_invlist(pTHX_ SV* const invlist, const UV start, const UV end) @@ -6535,6 +6537,7 @@ Perl__invlist_populate_swatch(pTHX_ SV* const invlist, const UV start, const UV return; } + void Perl__invlist_union_maybe_complement_2nd(pTHX_ SV* const a, SV* const b, bool complement_b, SV** output) { @@ -10478,18 +10481,7 @@ parseit: /* Invert if asking for the complement */ if (value == 'P') { - - /* Add to any existing list */ - if (! properties) { - properties = invlist_clone(invlist); - _invlist_invert(properties); - } - else { - invlist = invlist_clone(invlist); - _invlist_invert(invlist); - _invlist_union(properties, invlist, &properties); - SvREFCNT_dec(invlist); - } + _invlist_union_complement_2nd(properties, invlist, &properties); /* The swash can't be used as-is, because we've * inverted things; delay removing it to here after |