Open numist opened 4 years ago
Looks like reversing the order of the changes passed into CollectionDifference.init(:)
cuts the sorting time in half. Still lots more improvement for the built-in diffing algorithm to be made by moving the sort up out of CollectionDifference.init(validatedChanges:)
though.
Finally hit 80/20 with
CollectionDifference.init(:)
:Most of that time is spent in
CollectionDifference.init(_validatedChanges:)
, which was supposed to be the fast path (it skips change validity checking):The diffing algorithms already produce changes in order, so there's room here for an even faster
_validatedChanges
initializer, and also a fast path through the public initializer that checks order to avoid an unnecessary sort.