From: David Mitchell Date: Sun, 6 Jun 2010 17:48:49 +0000 (+0100) Subject: micro-optimise a bit of trie code X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6dd2be570d715119e05672f6f0266d924022b65a;p=p5sagit%2Fp5-mst-13.2.git micro-optimise a bit of trie code --- diff --git a/regexec.c b/regexec.c index 5cdc3cc..38c4181 100644 --- a/regexec.c +++ b/regexec.c @@ -1774,14 +1774,13 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s, }); if ( base ) { U32 tmp; + I32 offset; if (charid && - (base + charid > trie->uniquecharcount ) - && (base + charid - 1 - trie->uniquecharcount - < trie->lasttrans) - && trie->trans[base + charid - 1 - - trie->uniquecharcount].check == state - && (tmp=trie->trans[base + charid - 1 - - trie->uniquecharcount ].next)) + ( ((offset = base + charid + - 1 - trie->uniquecharcount)) >= 0) + && ((U32)offset < trie->lasttrans) + && trie->trans[offset].check == state + && (tmp=trie->trans[offset].next)) { DEBUG_TRIE_EXECUTE_r( PerlIO_printf( Perl_debug_log," - legal\n")); @@ -3197,6 +3196,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) /* read a char and goto next state */ if ( base ) { + I32 offset; REXEC_TRIE_READ_CHAR(trie_type, trie, widecharmap, uc, uscan, len, uvc, charid, foldlen, foldbuf, uniflags); @@ -3204,14 +3204,13 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) if (foldlen>0) ST.longfold = TRUE; if (charid && - (base + charid > trie->uniquecharcount ) - && (base + charid - 1 - trie->uniquecharcount - < trie->lasttrans) - && trie->trans[base + charid - 1 - - trie->uniquecharcount].check == state) + ( ((offset = + base + charid - 1 - trie->uniquecharcount)) >= 0) + + && ((U32)offset < trie->lasttrans) + && trie->trans[offset].check == state) { - state = trie->trans[base + charid - 1 - - trie->uniquecharcount ].next; + state = trie->trans[offset].next; } else { state = 0;