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