From: Michael Tremer Date: Wed, 25 Nov 2020 14:42:26 +0000 (+0000) Subject: network-list: Do not half list when popping the first element X-Git-Tag: 0.9.5~23 X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Flibloc.git;a=commitdiff_plain;h=673e03f7bfc807248a769cb00ec80f0fa2af7a25 network-list: Do not half list when popping the first element The list was unfortunately halved in size every time an element was taken from it, which was great for performance, but shortened the result substantially. Signed-off-by: Michael Tremer --- diff --git a/src/network-list.c b/src/network-list.c index 2c4edb3..f4a9d05 100644 --- a/src/network-list.c +++ b/src/network-list.c @@ -261,10 +261,13 @@ LOC_EXPORT struct loc_network* loc_network_list_pop_first(struct loc_network_lis struct loc_network* network = list->elements[0]; // Move all elements to the top of the stack - for (unsigned int i = 0; i < --list->size; i++) { + for (unsigned int i = 0; i < list->size - 1; i++) { list->elements[i] = list->elements[i+1]; } + // The list is shorter now + --list->size; + DEBUG(list->ctx, "%p: Popping network %p from stack\n", list, network); return network;