This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
reginclass: Reorder fastest first
authorKarl Williamson <public@khwilliamson.com>
Sun, 31 Oct 2010 19:17:34 +0000 (13:17 -0600)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 31 Oct 2010 23:15:32 +0000 (16:15 -0700)
commit7cdde5444c9ad8cccf237ec340ddb54f58ce3cf0
tree0995926659c26d2ff1bd4e8ea72602d47f5c5a45
parentea6756a64e0a36eb91bcea39467a2253c31192b8
reginclass: Reorder fastest first

This patch simply moves the block of code that does the bitmap tests in
front of the block of code that deals with potential things not in the
bit map.  The reason to do this is that it is faster to find things in
the bitmap, than to have to create a utf8 swash.

The patch also adds some comments, and the first block doesn't have to
test if there has been a match, and the second block does, so if
statements for those two blocks are adjusted accordingly.

The proof that this doesn't break anything stems from the fact that the
routine never stops early.  If there wasn't a match in the first block
of code, it would execute the second block.  Thus swapping the order
doesn't affect the outcome.  The side effects of the first block are
reading in the swash.  These side effects won't happen if it no longer
gets executed, because the other block matched.  And thus an error could
be introduced if there were coding errors elsewhere that didn't
initialize the swash before using it.  But that doesn't appear to be the
case, as all tests pass.
regexec.c