From 5f279dea76df756c2d9844a8e868f70b8716365c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?FabioLeit=C3=A3o?= Date: Sat, 6 Jun 2026 19:44:25 -0300 Subject: [PATCH] install_remove: avoid redundant apt cache init on startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MintLocale.__init__ already builds the apt cache (line 56) before calling build_lang_list(), which unconditionally rebuilds it (line 136). This wastes ~0.4 s on every launch. Add a refresh_cache parameter (default True) to build_lang_list so the init call can skip the redundant rebuild while post-operation calls (on_install_finished, button_add_clicked, button_remove_clicked) still get a fresh cache after package changes. Fixes: #92 Signed-off-by: FabioLeitão --- usr/lib/linuxmint/mintlocale/install_remove.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/usr/lib/linuxmint/mintlocale/install_remove.py b/usr/lib/linuxmint/mintlocale/install_remove.py index b30b31a..76cc8b6 100755 --- a/usr/lib/linuxmint/mintlocale/install_remove.py +++ b/usr/lib/linuxmint/mintlocale/install_remove.py @@ -94,7 +94,7 @@ def __init__(self): ren.set_property('xpad', 10) self.treeview.append_column(column) - self.build_lang_list() + self.build_lang_list(refresh_cache=False) self.apt = aptkit.simpleclient.SimpleAPTClient(self.window) @@ -132,8 +132,9 @@ def split_locale(self, locale_code): return (language_code, country_code, language_label) - def build_lang_list(self): - self.cache = apt_pkg.Cache(None) + def build_lang_list(self, refresh_cache=True): + if refresh_cache: + self.cache = apt_pkg.Cache(None) self.builder.get_object('button_install').set_sensitive(False) self.builder.get_object('button_remove').set_sensitive(False)