Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit e3801cf

Browse files
committed
Merge pull request #1667 from maicki/SmallASDataControllerImprovements
[ASDataController] Small improvements
2 parents 50ca58f + 6945555 commit e3801cf

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

AsyncDisplayKit/Details/ASDataController.mm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDat
782782

783783
[_editingTransactionQueue waitUntilAllOperationsAreFinished];
784784

785-
// sort indexPath to avoid messing up the index when inserting in several batches
785+
// Sort indexPath to avoid messing up the index when inserting in several batches
786786
NSArray *sortedIndexPaths = [indexPaths sortedArrayUsingSelector:@selector(compare:)];
787787
NSMutableArray<ASIndexedNodeContext *> *contexts = [[NSMutableArray alloc] initWithCapacity:indexPaths.count];
788788

@@ -815,7 +815,7 @@ - (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDat
815815

816816
[_editingTransactionQueue waitUntilAllOperationsAreFinished];
817817

818-
// sort indexPath in order to avoid messing up the index when deleting
818+
// Sort indexPath in order to avoid messing up the index when deleting in several batches.
819819
// FIXME: Shouldn't deletes be sorted in descending order?
820820
NSArray *sortedIndexPaths = [indexPaths sortedArrayUsingSelector:@selector(compare:)];
821821

@@ -838,25 +838,25 @@ - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDat
838838
[self accessDataSourceWithBlock:^{
839839
NSMutableArray<ASIndexedNodeContext *> *contexts = [[NSMutableArray alloc] initWithCapacity:indexPaths.count];
840840

841-
// FIXME: This doesn't currently do anything
841+
// Sort indexPath to avoid messing up the index when deleting
842842
// FIXME: Shouldn't deletes be sorted in descending order?
843-
[indexPaths sortedArrayUsingSelector:@selector(compare:)];
843+
NSArray *sortedIndexPaths = [indexPaths sortedArrayUsingSelector:@selector(compare:)];
844844

845845
id<ASEnvironment> environment = [self.environmentDelegate dataControllerEnvironment];
846846
ASEnvironmentTraitCollection environmentTraitCollection = environment.environmentTraitCollection;
847847

848-
for (NSIndexPath *indexPath in indexPaths) {
848+
for (NSIndexPath *indexPath in sortedIndexPaths) {
849849
ASCellNodeBlock nodeBlock = [_dataSource dataController:self nodeBlockAtIndexPath:indexPath];
850850
ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:ASDataControllerRowNodeKind atIndexPath:indexPath];
851851
[contexts addObject:[[ASIndexedNodeContext alloc] initWithNodeBlock:nodeBlock
852852
indexPath:indexPath
853853
constrainedSize:constrainedSize
854854
environmentTraitCollection:environmentTraitCollection]];
855855
}
856-
856+
857857
[_editingTransactionQueue addOperationWithBlock:^{
858858
LOG(@"Edit Transaction - reloadRows: %@", indexPaths);
859-
[self _deleteNodesAtIndexPaths:indexPaths withAnimationOptions:animationOptions];
859+
[self _deleteNodesAtIndexPaths:sortedIndexPaths withAnimationOptions:animationOptions];
860860
[self _batchLayoutNodesFromContexts:contexts withAnimationOptions:animationOptions];
861861
}];
862862
}];
@@ -875,7 +875,7 @@ - (void)relayoutAllNodes
875875
// (see _layoutNodes:atIndexPaths:withAnimationOptions:).
876876
[_editingTransactionQueue addOperationWithBlock:^{
877877
[_mainSerialQueue performBlockOnMainThread:^{
878-
for (NSString *kind in [_completedNodes keyEnumerator]) {
878+
for (NSString *kind in _completedNodes) {
879879
[self _relayoutNodesOfKind:kind];
880880
}
881881
}];

0 commit comments

Comments
 (0)