diff options
author | Karl Williamson <public@khwilliamson.com> | 2011-11-28 09:43:54 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2012-01-12 20:35:14 -0700 |
commit | f117c5cdb6988b0c8e9a34fc7907bb0d86e5549b (patch) | |
tree | 64899292339a21a0bedb3bfc0f10848da60aacae | |
parent | ea0d21094e33ba043129ab03e7e06a61e95503f5 (diff) | |
download | perl-f117c5cdb6988b0c8e9a34fc7907bb0d86e5549b.tar.gz |
regcomp.c: Pass inversion list directly to regexec.c
Currently, any generated inversion list is stringified and passed in the
data structure to regexec.c as such. regexec.c then calls
_core_swash_init() to convert it into a swash and back into an inversion
list. This intermediate step is wasteful, and this commit dispenses
with it, based on preparatory commits in regexec.c and utf8.c
-rw-r--r-- | regcomp.c | 38 |
1 files changed, 17 insertions, 21 deletions
@@ -10950,24 +10950,10 @@ parseit: return ret; } - if (nonbitmap) { - UV start, end; - invlist_iterinit(nonbitmap); - while (invlist_iternext(nonbitmap, &start, &end)) { - if (start == end) { - Perl_sv_catpvf(aTHX_ listsv, "%04"UVxf"\n", start); - } - else { - /* The \t sets the whole range */ - Perl_sv_catpvf(aTHX_ listsv, "%04"UVxf"\t%04"UVxf"\n", - /* XXX EBCDIC */ - start, end); - } - } - SvREFCNT_dec(nonbitmap); - } - - if (SvCUR(listsv) == initial_listsv_len && ! unicode_alternate) { + if (! nonbitmap + && SvCUR(listsv) == initial_listsv_len + && ! unicode_alternate) + { ARG_SET(ret, ANYOF_NONBITMAP_EMPTY); SvREFCNT_dec(listsv); SvREFCNT_dec(unicode_alternate); @@ -10981,9 +10967,18 @@ parseit: * to initialize the appropriate swash (which gets stored in * element [1]), and also useful for dumping the regnode. * Element [2] stores the multicharacter foldings, - * used later (regexec.c:S_reginclass()). */ - av_store(av, 0, listsv); + * used later (regexec.c:S_reginclass()). + * Element [3] stores the nonbitmap inversion list for use in addition + * or instead of element [0]. + * Element [4] is currently FALSE */ + av_store(av, 0, (SvCUR(listsv) == initial_listsv_len) + ? &PL_sv_undef + : listsv); av_store(av, 1, NULL); /* Placeholder for generated swash */ + if (nonbitmap) { + av_store(av, 3, nonbitmap); + av_store(av, 4, newSVuv(0)); + } /* Store any computed multi-char folds only if we are allowing * them */ @@ -11798,7 +11793,7 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o) SV *lv; /* Set if there is something outside the bit map */ SV * const sw = regclass_swash(prog, o, FALSE, &lv, 0); - if (lv) { + if (lv && lv != &PL_sv_undef) { if (sw) { U8 s[UTF8_MAXBYTES_CASE+1]; @@ -11856,6 +11851,7 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o) Safefree(origs); } + SvREFCNT_dec(lv); } } |