Closed alvaro-berruezo-unity3d closed 6 months ago
The performance issue is already fixed by https://github.com/AvaloniaUI/Avalonia.Controls.TreeDataGrid/pull/273 Now the Equals function is not heavily used when expanding rows, so we can discard this PR
What does the pull request do?
Improves the performance of the
Equals
function, as well as the==
and!=
operations, by pre-calculating the hash code in the constructor and using it to compare the objects.What is the current behavior?
When two
IndexPath
objects are compared for equality, theCompareTo
method is executed, which can be too slow when comparing a large number ofIndexPaths
TheIndexPaths
comparison is a limitation when trying to expand all nodes in a large tree, because it is a very heavily used operation used to convert model indexes to row indexes.What is the updated/expected behavior with this PR?
In every constructor of the
IndexPath
we calculate the hash code and store it in a member. Then this member is used whenever we need to compare twoIndexPath
objects for equality, which is much faster than using theCompareTo
method.