Skip to content

Commit

Permalink
Merge pull request #17771 from ghalliday/movetoHead
Browse files Browse the repository at this point in the history
HPCC-30291 Minor optimization of DLIstOf::moveToHead()

Reviewed-by: Mark Kelly [email protected]
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Sep 15, 2023
2 parents e6c4c19 + bba5aa8 commit 411d7f6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions system/jlib/jqueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,17 @@ class DListOf
//Initial code from remove() - simplified since pHead != element, and no decrement of entries
ELEMENT * next = element->next;
ELEMENT * prev = element->prev;
assertex(prev || next);
if (element == pTail) // would if (!next) avoid loading pTail?
pTail = prev;
if (next)
assertex(prev); // not at the head of the list, so must have a predecessor
if (likely(next))
{
next->prev = prev;
if (prev)
prev->next = next;
}
else
{
pTail = prev;
}

prev->next = next;

//enqueueHead() - simplified since pHead must be set, and no increment of number of entries
pHead->prev = element;
Expand Down

0 comments on commit 411d7f6

Please sign in to comment.