Change SelectedItems to HashSet, add SelectMany method#50
Open
ThereGoesMySanity wants to merge 1 commit intoRedth:mainfrom
Open
Change SelectedItems to HashSet, add SelectMany method#50ThereGoesMySanity wants to merge 1 commit intoRedth:mainfrom
ThereGoesMySanity wants to merge 1 commit intoRedth:mainfrom
Conversation
rdieske
suggested changes
Jan 23, 2025
| var newSelections = virtualListView?.SelectedItems ?? Array.Empty<ItemPosition>(); | ||
| ISet<ItemPosition> newSelections = virtualListView?.SelectedItems ?? new HashSet<ItemPosition>(); | ||
|
|
||
| if (virtualListView.SelectionMode == SelectionMode.None) |
There was a problem hiding this comment.
I have a small refactoring suggestion, as i wonder if this needs to be checked for null as well? I Mean when virtualListView is null, it throws a NullReferenceException.
So in the current state when we have a virtualListView of null we have a new HashSet on Line 107 but cannot continue, as it should throw an exception on Line 109/111
Suggested change
| if (virtualListView.SelectionMode == SelectionMode.None) | |
| if (virtualListView?.SelectionMode == SelectionMode.None) |
| if (virtualListView.SelectionMode == SelectionMode.None) | ||
| newSelections = Array.Empty<ItemPosition>(); | ||
| newSelections = new HashSet<ItemPosition>(); | ||
| else if (virtualListView.SelectionMode == SelectionMode.Single && newSelections.Count > 1) |
There was a problem hiding this comment.
I see the same problem here
Suggested change
| else if (virtualListView.SelectionMode == SelectionMode.Single && newSelections.Count > 1) | |
| else if (virtualListView?.SelectionMode == SelectionMode.Single && newSelections.Count > 1) |
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.
I was noticing very poor performance when trying to implement a "Select All" button for lists of ~5000 elements. Refactoring SelectedItems to use a HashSet provides major performance improvements. Also added a SelectMany method that only updates the property once.