]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Rearrange ac state.
authorAnoop Saldanha <anoopsaldanha@gmail.com>
Thu, 14 Mar 2013 13:25:52 +0000 (18:55 +0530)
committerVictor Julien <victor@inliniac.net>
Thu, 29 Aug 2013 12:48:56 +0000 (14:48 +0200)
Notice a minor speed bump of around 2% on runs.  More updates to follow.

src/util-mpm-ac.c

index 0e149547b71e7c21228b70cd52fd19ebfd4d5300..5208dd1f66c7e9b9fa8f4c0f8f25e1520de53c45 100644 (file)
@@ -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 */