From e252c8808b52b4d8d5ebdcccca519b26680d3648 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Sun, 29 Jun 2025 23:19:28 +0200 Subject: [PATCH] optimise updateCardCounts --- src/gui/set/cards_panel.cpp | 11 +++++++++++ src/gui/set/cards_panel.hpp | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/set/cards_panel.cpp b/src/gui/set/cards_panel.cpp index 0263d035..77e59072 100644 --- a/src/gui/set/cards_panel.cpp +++ b/src/gui/set/cards_panel.cpp @@ -107,6 +107,17 @@ void CardsPanel::updateCardCounts() { int selected = card_list->GetSelectedItemCount(); int filtered = card_list->GetItemCount(); int total = set->cards.size(); + + if ( + selected_cards_count == selected + && filtered_cards_count == filtered + && total_cards_count == total + ) return; + + selected_cards_count = selected; + filtered_cards_count = filtered; + total_cards_count = total; + if (filtered == total) { counts->SetLabel(_TOOL_2_("card counts 2", wxString::Format(wxT("%i"), selected), diff --git a/src/gui/set/cards_panel.hpp b/src/gui/set/cards_panel.hpp index 44c9060e..3abd5aaa 100644 --- a/src/gui/set/cards_panel.hpp +++ b/src/gui/set/cards_panel.hpp @@ -92,7 +92,10 @@ private: bool notes_below_editor; /// Update card counts - void updateCardCounts(); + void updateCardCounts(); + int selected_cards_count = 0; + int filtered_cards_count = 0; + int total_cards_count = 0; /// Move the notes panel below the editor or below the card list void updateNotesPosition(); // before Layout, call updateNotesPosition.