Skip to content

install_remove: avoid redundant apt cache init on startup#95

Open
FabioLeitao wants to merge 1 commit into
linuxmint:masterfrom
FabioLeitao:mintlocale-speedup-cache-init
Open

install_remove: avoid redundant apt cache init on startup#95
FabioLeitao wants to merge 1 commit into
linuxmint:masterfrom
FabioLeitao:mintlocale-speedup-cache-init

Conversation

@FabioLeitao

Copy link
Copy Markdown

Fixes #92.

MintLocale.__init__ builds self.cache = apt_pkg.Cache(None) at line 56, then immediately calls build_lang_list() which unconditionally rebuilds the cache at line 136. Each apt_pkg.Cache(None) call takes ~0.4 s, so the startup pays for it twice with no benefit.

Fix: add a refresh_cache=True parameter to build_lang_list. The __init__ call passes refresh_cache=False to skip the redundant rebuild. The three post-operation calls (on_install_finished, button_add_clicked, button_remove_clicked) use the default True and still get a fresh cache after package changes.

Result: ~0.4 s faster startup (one apt_pkg.Cache(None) instead of two), matching the benchmark in #92.

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: linuxmint#92
Signed-off-by: FabioLeitão <fabio.tleitao@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Speedup opportunity in install_remove.py

1 participant