Browse Source

Merge pull request #15577 from ghalliday/issue26823

HPCC-26823 Minor optimization to queue_t::pop()

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 3 years ago
parent
commit
2f4783951d
1 changed files with 3 additions and 3 deletions
  1. 3 3
      roxie/udplib/udpsha.cpp

+ 3 - 3
roxie/udplib/udpsha.cpp

@@ -163,23 +163,23 @@ DataBuffer *queue_t::pop(bool block)
     unsigned signalFreeSlots = 0;
     {
         CriticalBlock b(c_region);
-        if (!count)
+        if (unlikely(!count))
             return nullptr;
         count--;
         ret = head;
-        head = head->msgNext;
+        head = ret->msgNext;
         if (!head)
         {
             assert(!count);
             tail = nullptr;
         }
-        ret->msgNext = nullptr;
         if (count < limit && signal_free_sl)
         {
             signal_free_sl--;
             signalFreeSlots++;
         }
     }
+    ret->msgNext = nullptr;
     if (signalFreeSlots)
         free_sl.signal(signalFreeSlots);
     return ret;