From: Max Kellermann Date: Tue, 21 Mar 2017 21:28:14 +0000 (+0100) Subject: wreadln: call g_list_length() only once X-Git-Tag: v0.27~11 X-Git-Url: https://git.tokkee.org/?p=ncmpc.git;a=commitdiff_plain;h=1ba62833dcd82e0b637b7a56eaea785e2c3c49a9 wreadln: call g_list_length() only once --- diff --git a/src/wreadln.c b/src/wreadln.c index f45e474..4dde082 100644 --- a/src/wreadln.c +++ b/src/wreadln.c @@ -592,13 +592,15 @@ _wreadln(WINDOW *w, *history = g_list_delete_link(*history, hcurrent); } - while (g_list_length(*history) > wrln_max_history_length) { + unsigned history_length = g_list_length(*history); + while (history_length > wrln_max_history_length) { GList *first = g_list_first(*history); /* remove the oldest history entry */ g_free(first->data); first->data = NULL; *history = g_list_delete_link(*history, first); + --history_length; } }