diff options
author | antirez <antirez@gmail.com> | 2020-04-08 12:55:57 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2020-04-08 12:55:57 +0200 |
commit | 96a54866ab4694cf338af0441f28aa69e9643376 (patch) | |
tree | b5112868ce86b91bf84054d622f181882320d2ea /src/adlist.c | |
parent | 96688aa6462f330dfd4780d222ce4806d766ff33 (diff) | |
download | redis-96a54866ab4694cf338af0441f28aa69e9643376.tar.gz |
Speedup: unblock clients on keys in O(1).o1-bpop
See #7071.
Diffstat (limited to 'src/adlist.c')
-rw-r--r-- | src/adlist.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/adlist.c b/src/adlist.c index ec5f8bbf4..0fedc0729 100644 --- a/src/adlist.c +++ b/src/adlist.c @@ -327,12 +327,11 @@ listNode *listIndex(list *list, long index) { } /* Rotate the list removing the tail node and inserting it to the head. */ -void listRotate(list *list) { - listNode *tail = list->tail; - +void listRotateTailToHead(list *list) { if (listLength(list) <= 1) return; /* Detach current tail */ + listNode *tail = list->tail; list->tail = tail->prev; list->tail->next = NULL; /* Move it as head */ @@ -342,6 +341,21 @@ void listRotate(list *list) { list->head = tail; } +/* Rotate the list removing the head node and inserting it to the tail. */ +void listRotateHeadToTail(list *list) { + if (listLength(list) <= 1) return; + + listNode *head = list->head; + /* Detach current head */ + list->head = head->next; + list->head->prev = NULL; + /* Move it as tail */ + list->tail->next = head; + head->next = NULL; + head->prev = list->tail; + list->tail = head; +} + /* Add all the elements of the list 'o' at the end of the * list 'l'. The list 'other' remains empty but otherwise valid. */ void listJoin(list *l, list *o) { |