regcomp.c: small efficiency gain
authorKarl Williamson <public@khwilliamson.com>
Fri, 3 Dec 2010 17:36:22 +0000 (10:36 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 4 Dec 2010 20:07:00 +0000 (12:07 -0800)
commit3c8eea2bac1e0e284a82cc7242e6a704ab97b6bf
tree8b4ce648faae71252858ce1fb2c575dce068418b
parentced7f09023f51e105efcf75e3b73986b408608ae
regcomp.c: small efficiency gain

The 7-bit test operations always fail on non-ascii characters, therefore
it isn't needed to test each such character individually.  The loops
that do that and then set a bit for each character can therefore stop at
127 instead of 255 (the bitmaps are initialized to all zeros).  For
EBCDIC, the same applies, except that we have to map those 7-bits
characters to the 8-bit EBCDIC range.  This creates an extra array
lookup for each ebcdic character, but half as many times through the
loop.

For the complement of the 7-bit operations, we know that they will all
be set for the non-ascii characters.  Therefore, we don't need to test,
we can just unconditionally set those bits.  It would not be a good idea
to just do a memset on that range under /i, as each character that gets
chosen may have its fold added as well and that has to be looked up
individually.
regcomp.c