From a6ad8ef73e258936fc54956684f6fc8945ca26a0 Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Tue, 22 Aug 2006 00:45:22 -0700 Subject: [PATCH] --- yaml --- r: 33448 b: refs/heads/master c: 3ffaa8c7c0f884171a273cd2145b8fbbf233ba22 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/lib/ts_bm.c | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index 0d952d97d860..9bb03439f4b4 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 316c1592bea94ead75301cb764523661fbbcc1ca +refs/heads/master: 3ffaa8c7c0f884171a273cd2145b8fbbf233ba22 diff --git a/trunk/lib/ts_bm.c b/trunk/lib/ts_bm.c index 0110e4414805..d90822c378a4 100644 --- a/trunk/lib/ts_bm.c +++ b/trunk/lib/ts_bm.c @@ -111,15 +111,14 @@ static int subpattern(u8 *pattern, int i, int j, int g) return ret; } -static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern, - unsigned int len) +static void compute_prefix_tbl(struct ts_bm *bm) { int i, j, g; for (i = 0; i < ASIZE; i++) - bm->bad_shift[i] = len; - for (i = 0; i < len - 1; i++) - bm->bad_shift[pattern[i]] = len - 1 - i; + bm->bad_shift[i] = bm->patlen; + for (i = 0; i < bm->patlen - 1; i++) + bm->bad_shift[bm->pattern[i]] = bm->patlen - 1 - i; /* Compute the good shift array, used to match reocurrences * of a subpattern */ @@ -150,8 +149,8 @@ static struct ts_config *bm_init(const void *pattern, unsigned int len, bm = ts_config_priv(conf); bm->patlen = len; bm->pattern = (u8 *) bm->good_shift + prefix_tbl_len; - compute_prefix_tbl(bm, pattern, len); memcpy(bm->pattern, pattern, len); + compute_prefix_tbl(bm); return conf; }