From 3f5280987e779d209ce5a4ad25b4696dcabc4c03 Mon Sep 17 00:00:00 2001 From: David Maciejak Date: Tue, 3 Feb 2026 18:22:24 -0500 Subject: [PATCH] WINGs: refactor wlist This patch refactors wlist to bring some improvements to not count the list of entries at each loop iteration. --- WINGs/wlist.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/WINGs/wlist.c b/WINGs/wlist.c index 4136145c..8350095b 100644 --- a/WINGs/wlist.c +++ b/WINGs/wlist.c @@ -495,15 +495,16 @@ static void paintItem(List * lPtr, int index) static void paintList(List * lPtr) { W_Screen *scrPtr = lPtr->view->screen; - int i, lim; + int i, lim, itemCount; if (!lPtr->view->flags.mapped) return; - if (WMGetArrayItemCount(lPtr->items) > 0) { - if (lPtr->topItem + lPtr->fullFitLines + lPtr->flags.dontFitAll > WMGetArrayItemCount(lPtr->items)) { + itemCount = WMGetArrayItemCount(lPtr->items); + if (itemCount > 0) { + if (lPtr->topItem + lPtr->fullFitLines + lPtr->flags.dontFitAll > itemCount) { - lim = WMGetArrayItemCount(lPtr->items) - lPtr->topItem; + lim = itemCount - lPtr->topItem; XClearArea(scrPtr->display, lPtr->view->window, 19, 2 + lim * lPtr->itemHeight, lPtr->view->size.width - 21, lPtr->view->size.height - lim * lPtr->itemHeight - 3, False); @@ -820,7 +821,7 @@ void WMSetListSelectionToRange(WMList * lPtr, WMRange range) void WMSelectAllListItems(WMList * lPtr) { - int i; + int i, itemCount; WMListItem *item; if (!lPtr->flags.allowMultipleSelection) @@ -833,7 +834,8 @@ void WMSelectAllListItems(WMList * lPtr) WMFreeArray(lPtr->selectedItems); lPtr->selectedItems = WMCreateArrayWithArray(lPtr->items); - for (i = 0; i < WMGetArrayItemCount(lPtr->items); i++) { + itemCount = WMGetArrayItemCount(lPtr->items); + for (i = 0; i < itemCount; i++) { item = WMGetFromArray(lPtr->items, i); if (!item->selected) { item->selected = 1; @@ -859,10 +861,11 @@ void WMSelectAllListItems(WMList * lPtr) */ static void unselectAllListItems(WMList * lPtr, WMListItem * exceptThis) { - int i; + int i, itemCount; WMListItem *item; - for (i = 0; i < WMGetArrayItemCount(lPtr->items); i++) { + itemCount = WMGetArrayItemCount(lPtr->items); + for (i = 0; i < itemCount; i++) { item = WMGetFromArray(lPtr->items, i); if (item != exceptThis && item->selected) { item->selected = 0;