]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
UE-2991: avoid copying one unnecessary subqueue item
authorXiang Wang <xiang.w.wang@intel.com>
Mon, 11 Jul 2016 14:08:40 +0000 (10:08 -0400)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 10 Aug 2016 04:59:06 +0000 (14:59 +1000)
src/nfa/tamarama.c

index b7ba126c265d86064649d9ff63684957cb920d24..4286a67e5482f2dd471afae4a8a8987f92dc1972 100644 (file)
@@ -243,13 +243,15 @@ void copyBack(const struct  Tamarama *t, struct mq *q, struct mq *q1) {
     u32 numItems = q1->end > q1->cur + 1 ? q1->end - q1->cur - 1 : 1;
     // Also need to copy MQE_END if the main queue is empty
     if (q->cur == q->end) {
-        numItems++;
+        assert(q->cur > 1 && q1->items[q1->end - 1].type == MQE_END);
+        q->items[--q->cur] = q1->items[q1->end - 1];
     }
     u32 cur = q->cur - numItems;
     q->items[cur] = q1->items[q1->cur++];
     q->items[cur].type = MQE_START;
     q->cur = cur++;
     for (u32 i = 0; i < numItems - 1; ++i) {
+        assert(q1->cur < q1->end);
         u32 type = q1->items[q1->cur].type;
         if (type > MQE_END) {
             q1->items[q1->cur].type = type - event_base + base;