diff options
author | David Mitchell <davem@iabyn.com> | 2010-06-06 18:48:49 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2010-06-06 18:52:27 +0100 |
commit | 6dd2be570d715119e05672f6f0266d924022b65a (patch) | |
tree | 8df0a83c80e0e0f443aacf64d4fba6e940ff1f73 /regexec.c | |
parent | 0bf6a637d180d2ff237212513f8b816d40ead86a (diff) | |
download | perl-6dd2be570d715119e05672f6f0266d924022b65a.tar.gz |
micro-optimise a bit of trie code
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 27 |
1 files changed, 13 insertions, 14 deletions
@@ -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; |