Don't save registry when opening settings #3058
Merged
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.
Motivation
I recently noticed that opening the settings window is pretty slow from time to time. When profiling it, I found out that we save the registry on settings startup, and it seems to be the culprit (the serialization, to be precise).
Problem
In
RefreshReposListBox>()
, the registry is saved after the we sort the list of repositories in the registry to how they are sorted in the GUI.This is also done when the settings are just opened. In this case there are no repositories listed in the GUI (and the user couldn't have changed the sorting yet), so the whole operation is not doing anything.
However we still save the registry afterwards, which takes a long time.
Changes
THe costly operation is put behind an if-clause. When
_sortedRepos.Count == 0
, we just pull the list of repositories from the registry (needed to build the list for the GUI later), but jump over all the sorting and saving stuff.