From c09b5941ce31be3cb08818533917afdeaf799575 Mon Sep 17 00:00:00 2001 From: sundb Date: Mon, 9 Nov 2020 20:16:09 +0800 Subject: [PATCH] optimization src/adlist.c:listJoin() --- src/adlist.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/adlist.c b/src/adlist.c index bc06ffc8f..7670b2c10 100644 --- a/src/adlist.c +++ b/src/adlist.c @@ -360,15 +360,16 @@ void listRotateHeadToTail(list *list) { /* 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) { - if (o->head) - o->head->prev = l->tail; + if (o->len == 0) return; + + o->head->prev = l->tail; if (l->tail) l->tail->next = o->head; else l->head = o->head; - if (o->tail) l->tail = o->tail; + l->tail = o->tail; l->len += o->len; /* Setup other as an empty list. */