From 1ba62833dcd82e0b637b7a56eaea785e2c3c49a9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 21 Mar 2017 22:28:14 +0100 Subject: [PATCH] wreadln: call g_list_length() only once --- src/wreadln.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; } } -- 2.30.2