diff --git a/include/aux.h b/include/aux.h index d4f4244b6..32b40b492 100644 --- a/include/aux.h +++ b/include/aux.h @@ -153,10 +153,19 @@ INLINE char *glib_json_print(JsonBuilder *builder) { /* GQUEUE */ +// appends `src` to the end of `dst` and clears out `src` INLINE void g_queue_move(GQueue *dst, GQueue *src) { - GList *l; - while ((l = g_queue_pop_head_link(src))) - g_queue_push_tail_link(dst, l); + if (!src->length) + return; + if (!dst->length) { + *dst = *src; + g_queue_init(src); + return; + } + dst->tail->next = src->head; + src->head->prev = dst->tail; + dst->length += src->length; + g_queue_init(src); } INLINE void g_queue_truncate(GQueue *q, unsigned int len) { while (q->length > len)