From: Jarkko Hietaniemi Date: Tue, 7 Nov 2000 15:51:13 +0000 (+0000) Subject: Shave off about 5% (Digital UNIX, -g, pixie) of the op/regexp X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=023851150e19d9fc4a9b3320c50e7fc5ccec014f;p=p5sagit%2Fp5-mst-13.2.git Shave off about 5% (Digital UNIX, -g, pixie) of the op/regexp execution time in regcomp.c S_cl_any() and S_cl_is_anything() by using memset() and testing bytewise (as opposed to bitwise). p4raw-id: //depot/perl@7590 --- diff --git a/regcomp.c b/regcomp.c index 19b8096..83470d7 100644 --- a/regcomp.c +++ b/regcomp.c @@ -427,11 +427,8 @@ S_scan_commit(pTHX_ scan_data_t *data) STATIC void S_cl_anything(pTHX_ struct regnode_charclass_class *cl) { - int value; - ANYOF_CLASS_ZERO(cl); - for (value = 0; value < 256; ++value) - ANYOF_BITMAP_SET(cl, value); + ANYOF_BITMAP_SETALL(cl); cl->flags = ANYOF_EOS; if (LOC) cl->flags |= ANYOF_LOCALE; @@ -446,8 +443,8 @@ S_cl_is_anything(pTHX_ struct regnode_charclass_class *cl) for (value = 0; value <= ANYOF_MAX; value += 2) if (ANYOF_CLASS_TEST(cl, value) && ANYOF_CLASS_TEST(cl, value + 1)) return 1; - for (value = 0; value < 256; ++value) - if (!ANYOF_BITMAP_TEST(cl, value)) + for (value = 0; value < ANYOF_BITMAP_SIZE; ++value) + if (!ANYOF_BITMAP_BYTE(cl, value)) return 0; return 1; } diff --git a/regcomp.h b/regcomp.h index 225ff74..b906b52 100644 --- a/regcomp.h +++ b/regcomp.h @@ -249,6 +249,7 @@ struct regnode_charclass_class { #define ANYOF_CLASS_ZERO(ret) Zero(((struct regnode_charclass_class*)(ret))->classflags, ANYOF_CLASSBITMAP_SIZE, char) #define ANYOF_BITMAP_ZERO(ret) Zero(((struct regnode_charclass*)(ret))->bitmap, ANYOF_BITMAP_SIZE, char) +#define ANYOF_BITMAP_SETALL(p) (memset(ANYOF_BITMAP(p), 0xff, ANYOF_BITMAP_SIZE)) #define ANYOF_BITMAP(p) (((struct regnode_charclass*)(p))->bitmap) #define ANYOF_BITMAP_BYTE(p, c) (ANYOF_BITMAP(p)[((c) >> 3) & 31])