X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=lib%2Fts_bm.c;h=d90822c378a48af52878f41e5db18858496fddb9;hb=25765c4e5de8edcd06b60993b63feeed9e7885c1;hp=c4c1ac5fbd1aea372553ce094171ff8c152b2433;hpb=a4e817ba24d2a52f0332c2ddcdbf77ddd6a92bbe;p=cascardo%2Flinux.git diff --git a/lib/ts_bm.c b/lib/ts_bm.c index c4c1ac5fbd1a..d90822c378a4 100644 --- a/lib/ts_bm.c +++ b/lib/ts_bm.c @@ -35,7 +35,6 @@ * matchings spread over multiple fragments, then go BM. */ -#include #include #include #include @@ -112,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 */ @@ -151,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; }