]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: bypass merge sort call if possible
authorVictor Julien <victor@inliniac.net>
Thu, 2 Nov 2017 11:44:29 +0000 (12:44 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 19 Jan 2018 09:16:52 +0000 (10:16 +0100)
src/detect.c

index 9367a854ab6b487323ba3b12c8cbe756805602c1..3b8ee921c53f80f9ccf9aa7b8ce858acba0983e4 100644 (file)
@@ -729,9 +729,12 @@ static inline void DetectRunPrefilterPkt(
 
     /* run the prefilter engines */
     Prefilter(det_ctx, scratch->sgh, p, scratch->flow_flags);
-    PACKET_PROFILING_DETECT_START(p, PROF_DETECT_PF_SORT2);
-    DetectPrefilterMergeSort(de_ctx, det_ctx);
-    PACKET_PROFILING_DETECT_END(p, PROF_DETECT_PF_SORT2);
+    /* create match list if we have non-pf and/or pf */
+    if (det_ctx->non_pf_store_cnt || det_ctx->pmq.rule_id_array_cnt) {
+        PACKET_PROFILING_DETECT_START(p, PROF_DETECT_PF_SORT2);
+        DetectPrefilterMergeSort(de_ctx, det_ctx);
+        PACKET_PROFILING_DETECT_END(p, PROF_DETECT_PF_SORT2);
+    }
 
 #ifdef PROFILING
     if (tv) {