diff --git a/Source/Private/ASLayoutTransition.mm b/Source/Private/ASLayoutTransition.mm index e9a09c1c8..77a8fdd7c 100644 --- a/Source/Private/ASLayoutTransition.mm +++ b/Source/Private/ASLayoutTransition.mm @@ -67,7 +67,6 @@ @implementation ASLayoutTransition { NSArray *_insertedSubnodes; NSArray *_removedSubnodes; std::vector _insertedSubnodePositions; - std::vector _removedSubnodePositions; std::vector> _subnodeMoves; } @@ -179,7 +178,7 @@ - (void)calculateSubnodeOperationsIfNeeded // IGListDiff completes in linear time O(m+n), so use it if we have it: IGListIndexSetResult *result = IGListDiff(previousLayout.sublayouts, pendingLayout.sublayouts, IGListDiffEquality); _insertedSubnodePositions = findNodesInLayoutAtIndexes(pendingLayout, result.inserts, &_insertedSubnodes); - _removedSubnodePositions = findNodesInLayoutAtIndexes(previousLayout, result.deletes, &_removedSubnodes); + findNodesInLayoutAtIndexes(previousLayout, result.deletes, &_removedSubnodes); for (IGListMoveIndex *move in result.moves) { _subnodeMoves.push_back(std::make_pair(previousLayout.sublayouts[move.from].layoutElement, move.to)); } @@ -192,16 +191,15 @@ - (void)calculateSubnodeOperationsIfNeeded #else NSIndexSet *insertions, *deletions; NSArray *moves; - [previousLayout.sublayouts asdk_diffWithArray:pendingLayout.sublayouts + NSArray *previousNodes = [previousLayout.sublayouts valueForKey:@"layoutElement"]; + NSArray *pendingNodes = [pendingLayout.sublayouts valueForKey:@"layoutElement"]; + [previousNodes asdk_diffWithArray:pendingNodes insertions:&insertions deletions:&deletions moves:&moves]; _insertedSubnodePositions = findNodesInLayoutAtIndexes(pendingLayout, insertions, &_insertedSubnodes); - _removedSubnodePositions = findNodesInLayoutAtIndexesWithFilteredNodes(previousLayout, - deletions, - _insertedSubnodes, - &_removedSubnodes); + _removedSubnodes = [previousNodes objectsAtIndexes:deletions]; // These should arrive sorted in ascending order of move destinations. for (NSIndexPath *move in moves) { _subnodeMoves.push_back(std::make_pair(previousLayout.sublayouts[([move indexAtPosition:0])].layoutElement, @@ -212,7 +210,6 @@ - (void)calculateSubnodeOperationsIfNeeded NSIndexSet *indexes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [pendingLayout.sublayouts count])]; _insertedSubnodePositions = findNodesInLayoutAtIndexes(pendingLayout, indexes, &_insertedSubnodes); _removedSubnodes = nil; - _removedSubnodePositions.clear(); } _calculatedSubnodeOperations = YES; }