This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regexec.c: Tighten loops in regrepeat()
authorKarl Williamson <public@khwilliamson.com>
Tue, 16 Oct 2012 16:56:28 +0000 (10:56 -0600)
committerKarl Williamson <public@khwilliamson.com>
Wed, 17 Oct 2012 03:48:37 +0000 (21:48 -0600)
commit613a425dda0dc9e3f838151a5d796c902cfd922e
treee1bfc7e5bdad859a2c63c3316496ac3e8738431b
parent79a2a0e89816b80870df1f9b9e7bb5fb1edcd556
regexec.c: Tighten loops in regrepeat()

regrepeat() is used to match some simple thing repeatedly in a row.  In
the case of EXACTFish nodes, it will repeat a single character (and its
fold).  Prior to this commit, it was using the full generality of
foldEQ_utf8() whenever the target was encoded in UTF-8.  This full
generality requires quite a bit of processing.  However, most
Unicode folds are of the simple variety containing just a character and
its upper- or lower-cased equivalent, and so the full generality of
foldEQ_utf8() is needed only comparatively infrequently.

This commit takes advantage of the newly added and enhanced
S_setup_EXACTISH_ST_c1_c2() to look at the character being repeated and
decide what level of generality is needed.  regrepeat() then uses a loop
that is only as complicated as needed.

This also adds some asserts that the nodes contain exactly 1 character
regexec.c