From: Anoop Saldanha Date: Thu, 14 Mar 2013 13:25:52 +0000 (+0530) Subject: Rearrange ac state. X-Git-Tag: suricata-2.0beta2~421 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8516ba24c903380aefd702eee9fc39bb63159ec8;p=thirdparty%2Fsuricata.git Rearrange ac state. Notice a minor speed bump of around 2% on runs. More updates to follow. --- diff --git a/src/util-mpm-ac.c b/src/util-mpm-ac.c index 0e149547b7..5208dd1f66 100644 --- a/src/util-mpm-ac.c +++ b/src/util-mpm-ac.c @@ -555,6 +555,27 @@ static inline void SCACCreateGotoTable(MpmCtx *mpm_ctx) return; } +static inline void SCACDetermineLevel1Gap(MpmCtx *mpm_ctx) +{ + SCACCtx *ctx = (SCACCtx *)mpm_ctx->ctx; + uint32_t u = 0; + + int map[256]; + memset(map, 0, sizeof(map)); + + for (u = 0; u < mpm_ctx->pattern_cnt; u++) + map[ctx->parray[u]->ci[0]] = 1; + + for (u = 0; u < 256; u++) { + if (map[u] == 0) + continue; + int32_t newstate = SCACInitNewState(mpm_ctx); + ctx->goto_table[0][u] = newstate; + } + + return; +} + static inline int SCACStateQueueIsEmpty(StateQueue *q) { if (q->top == q->bot) @@ -915,6 +936,8 @@ static inline void SCACPrepareStateTable(MpmCtx *mpm_ctx) /* create the 0th state in the goto table and output_table */ SCACInitNewState(mpm_ctx); + SCACDetermineLevel1Gap(mpm_ctx); + /* create the goto table */ SCACCreateGotoTable(mpm_ctx); /* create the failure table */