• cmemory's avatar
    improve quicklist insert head/tail while head/tail node is full. (#9113) · 27a68a4d
    cmemory authored
    In _quicklistInsert when `at_head` / `at_tail` is true, but `prev` / `next` is NULL,
    the code was reaching the last if-else block at the bottom of the function,
    and would have unnecessarily executed _quicklistSplitNode, instead of just creating a new node.
    This was because the penultimate if-else was checking `node->next && full_next`.
    but in fact it was unnecessary to check if `node->next` exists, if we're gonna create one anyway,
    we only care that it's not full, or doesn't exist, so the condition could have been changed to `!node->next || full_next`.
    
    Instead, this PR makes a small refactory to negate `full_next` to a more meaningful variable
    `avail_next` that indicates that the next node is available for pushing additional elements or
    not (this would be true only if it exists and it is non-full)
    27a68a4d
quicklist.c 105 KB