-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fixed ArgumentOutOfRangeException in AdvancedCollectionView #4349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -677,33 +677,17 @@ private bool HandleItemAdded(int newStartingIndex, object newItem, int? viewInde | |
| return false; | ||
| } | ||
|
|
||
| if (newStartingIndex == 0 || _view.Count == 0) | ||
| { | ||
| newViewIndex = 0; | ||
| } | ||
| else if (newStartingIndex == _source.Count - 1) | ||
| { | ||
| newViewIndex = _view.Count - 1; | ||
| } | ||
| else if (viewIndex.HasValue) | ||
| if (viewIndex.HasValue) | ||
| { | ||
| newViewIndex = viewIndex.Value; | ||
| } | ||
| else | ||
| { | ||
| for (int i = 0, j = 0; i < _source.Count; i++) | ||
| { | ||
| if (i == newStartingIndex) | ||
| { | ||
| newViewIndex = j; | ||
| break; | ||
| } | ||
|
|
||
| if (_view[j] == _source[i]) | ||
| { | ||
| j++; | ||
| } | ||
| } | ||
| newViewIndex = _view.Select(x => _source.IndexOf(x)) // Get indexes of all items that are currently in view | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely worried about the performance impact here, this seems like a lot of extra work and memory to determine this calculation.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it could impact on performance, but not sure about any other possible solutions right now. Someone should have to run benchmark stuff on this method to get a better overview.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the unit test you added shows the failure case at least, then it'd be good if we can figure out how to fix the original algorithm here. We wouldn't want to add extra overhead to this helper. This class is relatively isolated, so you may be able to pull it out to run benchmarking on it in isolation vs. trying to add benchmarking within the project. @Sergio0694 any tips/resources/articles to point @w-ahmad to for benchmarking code like this? |
||
| .Concat(new int[] { newStartingIndex }) // Add index of item that need to be inserted in view | ||
| .OrderBy(x => x) | ||
| .ToList() | ||
| .IndexOf(newStartingIndex); // Get the index for new item in view | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.