From 09687265be2a38fd35598ad49ccc916581acf366 Mon Sep 17 00:00:00 2001 From: permaloom Date: Sat, 7 Feb 2026 13:18:31 -0500 Subject: [PATCH] perf: optimize search by toggling flowbox child visibility Toggle visibility of flowbox children based on search text instead of rebuilding the entire flowbox on every keystroke, improving search performance. --- faugus_launcher.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/faugus_launcher.py b/faugus_launcher.py index bf80bed..a88f47b 100644 --- a/faugus_launcher.py +++ b/faugus_launcher.py @@ -1504,23 +1504,19 @@ class Main(Gtk.Window): def on_search_changed(self, entry): search_text = entry.get_text().lower() - self.filtered_games = [game for game in self.games if search_text in game.title.lower()] + first_visible = None for child in self.flowbox.get_children(): - self.flowbox.remove(child) + game = child.game + is_match = search_text in game.title.lower() - if self.filtered_games: - for game in self.filtered_games: - self.add_item_list(game) + child.set_visible(is_match) + if is_match and first_visible is None: + first_visible = child - first_child = self.flowbox.get_children()[0] - self.flowbox.select_child(first_child) - self.on_item_selected(self.flowbox, first_child) - - else: - pass - - self.flowbox.show_all() + if first_visible: + self.flowbox.select_child(first_visible) + self.on_item_selected(self.flowbox, first_visible) def on_item_selected(self, flowbox, child): if child is not None: