install_remove: avoid redundant apt cache init on startup#95
Open
FabioLeitao wants to merge 1 commit into
Open
install_remove: avoid redundant apt cache init on startup#95FabioLeitao wants to merge 1 commit into
FabioLeitao wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #92.
MintLocale.__init__buildsself.cache = apt_pkg.Cache(None)at line 56, then immediately callsbuild_lang_list()which unconditionally rebuilds the cache at line 136. Eachapt_pkg.Cache(None)call takes ~0.4 s, so the startup pays for it twice with no benefit.Fix: add a
refresh_cache=Trueparameter tobuild_lang_list. The__init__call passesrefresh_cache=Falseto skip the redundant rebuild. The three post-operation calls (on_install_finished,button_add_clicked,button_remove_clicked) use the defaultTrueand 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.