]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
limex: use cyclics mask for repeat compress
authorJustin Viiret <justin.viiret@intel.com>
Mon, 4 Jul 2016 04:19:10 +0000 (14:19 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 10 Aug 2016 04:52:56 +0000 (14:52 +1000)
src/nfa/limex_runtime_impl.h

index 95f18d1b07611d321b7e2383d28a1aaafc3a5699..d6c28c6f8f63cd9277528368184b12f5eaef5b99 100644 (file)
@@ -358,6 +358,11 @@ void COMPRESS_REPEATS_FN(const IMPL_NFA_T *limex, void *dest, void *src,
 
     STATE_T s = LOAD_STATE(src);
 
+    if (ISZERO_STATE(AND_STATE(s, LOAD_STATE(&limex->repeatCyclicMask)))) {
+        DEBUG_PRINTF("no cyclics are on\n");
+        return;
+    }
+
     const union RepeatControl *ctrl =
         getRepeatControlBaseConst((const char *)src, sizeof(STATE_T));
     char *state_base = (char *)dest + limex->stateSize;
@@ -407,7 +412,12 @@ void EXPAND_REPEATS_FN(const IMPL_NFA_T *limex, void *dest, const void *src,
     }
 
     // Note: state has already been expanded into 'dest'.
-    STATE_T s = LOAD_STATE(dest);
+    const STATE_T cyclics =
+        AND_STATE(LOAD_STATE(dest), LOAD_STATE(&limex->repeatCyclicMask));
+    if (ISZERO_STATE(cyclics)) {
+        DEBUG_PRINTF("no cyclics are on\n");
+        return;
+    }
 
     union RepeatControl *ctrl =
         getRepeatControlBase((char *)dest, sizeof(STATE_T));
@@ -417,7 +427,7 @@ void EXPAND_REPEATS_FN(const IMPL_NFA_T *limex, void *dest, const void *src,
         DEBUG_PRINTF("repeat %u\n", i);
         const struct NFARepeatInfo *info = GET_NFA_REPEAT_INFO_FN(limex, i);
 
-        if (!TESTBIT_STATE(&s, info->cyclicState)) {
+        if (!TESTBIT_STATE(&cyclics, info->cyclicState)) {
             DEBUG_PRINTF("is dead\n");
             continue;
         }