[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/15] Avoid using trie->depth during matching
From: |
Nick Cleaton |
Subject: |
[PATCH 08/15] Avoid using trie->depth during matching |
Date: |
Sat, 2 Oct 2010 07:07:44 +0100 |
This makes trie->depth into a field that is accessed only during
the trie preparation process and not while matching.
---
src/kwset.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/kwset.c b/src/kwset.c
index b8736a7..a408c3a 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -706,7 +706,7 @@ cwexec (kwset_t kws, char const *text, size_t len, struct
kwsmatch *kwsmatch)
char const *beg, *lim, *mch, *lmch;
unsigned char c;
unsigned char const *delta;
- int d;
+ int d, mch_len;
char const *end, *qlim;
char const *trans;
@@ -795,6 +795,7 @@ cwexec (kwset_t kws, char const *text, size_t len, struct
kwsmatch *kwsmatch)
lim = mch + kwset->maxd;
lmch = 0;
d = 1;
+ mch_len = end - mch;
while (lim - end >= d)
{
if ((d = delta[c = (end += d)[-1]]) != 0)
@@ -835,6 +836,7 @@ cwexec (kwset_t kws, char const *text, size_t len, struct
kwsmatch *kwsmatch)
if (lmch)
{
mch = lmch;
+ mch_len = end - mch;
goto match;
}
if (!d)
@@ -843,7 +845,7 @@ cwexec (kwset_t kws, char const *text, size_t len, struct
kwsmatch *kwsmatch)
kwsmatch->index = accept->accepting / 2;
kwsmatch->offset[0] = mch - text;
- kwsmatch->size[0] = accept->depth;
+ kwsmatch->size[0] = mch_len;
return mch - text;
}
--
1.5.6.3
- Proof of concept: kwset running 3 times smaller, Nick Cleaton, 2010/10/02
- [PATCH 01/15] Merge trie and tree into a single struct, Nick Cleaton, 2010/10/02
- [PATCH 02/15] Sort the keywords before building the trie, Nick Cleaton, 2010/10/02
- [PATCH 03/15] Lay out the trie more systematically, Nick Cleaton, 2010/10/02
- [PATCH 04/15] Lay out the trees more systematically, Nick Cleaton, 2010/10/02
- [PATCH 05/15] Avoid using llink and rlink during prep, Nick Cleaton, 2010/10/02
- [PATCH 06/15] Defer llink/rlink plumbing to the end of prep, Nick Cleaton, 2010/10/02
- [PATCH 07/15] Share storage between llink and fail, Nick Cleaton, 2010/10/02
- [PATCH 08/15] Avoid using trie->depth during matching,
Nick Cleaton <=
- [PATCH 09/15] Share storage between rlink and depth, Nick Cleaton, 2010/10/02
- [PATCH 10/15] Eliminate the trie->parent field, Nick Cleaton, 2010/10/02
- [PATCH 11/15] Eliminate the trie->next field, Nick Cleaton, 2010/10/02
- [PATCH 12/15] Eliminate the trie->maxshift field, Nick Cleaton, 2010/10/02
- [PATCH 13/15] Reduce trie->accepting to a flag, Nick Cleaton, 2010/10/02
- [PATCH 14/15] Merge flags into a trie->flags field, Nick Cleaton, 2010/10/02
- [PATCH 15/15] Make trie->shift an unsigned short, Nick Cleaton, 2010/10/02
- Re: Proof of concept: kwset running 3 times smaller, Nick Cleaton, 2010/10/30