mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 11:20:18 +00:00
[ASCollectionDataController] Use block-based enumeration with dictionaries
This commit is contained in:
parent
9cd606d182
commit
8eb25e737b
@ -88,8 +88,7 @@
|
|||||||
|
|
||||||
- (void)willInsertSections:(NSIndexSet *)sections
|
- (void)willInsertSections:(NSIndexSet *)sections
|
||||||
{
|
{
|
||||||
for (NSString *kind in _pendingContexts) {
|
[_pendingContexts enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull kind, NSMutableArray<ASIndexedNodeContext *> * _Nonnull contexts, BOOL * _Nonnull stop) {
|
||||||
NSMutableArray<ASIndexedNodeContext *> *contexts = _pendingContexts[kind];
|
|
||||||
NSMutableArray *sectionArray = [NSMutableArray arrayWithCapacity:sections.count];
|
NSMutableArray *sectionArray = [NSMutableArray arrayWithCapacity:sections.count];
|
||||||
for (NSUInteger i = 0; i < sections.count; i++) {
|
for (NSUInteger i = 0; i < sections.count; i++) {
|
||||||
[sectionArray addObject:[NSMutableArray array]];
|
[sectionArray addObject:[NSMutableArray array]];
|
||||||
@ -99,7 +98,7 @@
|
|||||||
[self batchLayoutNodesFromContexts:contexts ofKind:kind completion:^(NSArray<ASCellNode *> *nodes, NSArray<NSIndexPath *> *indexPaths) {
|
[self batchLayoutNodesFromContexts:contexts ofKind:kind completion:^(NSArray<ASCellNode *> *nodes, NSArray<NSIndexPath *> *indexPaths) {
|
||||||
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
|
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
|
||||||
}];
|
}];
|
||||||
}
|
}];
|
||||||
[_pendingContexts removeAllObjects];
|
[_pendingContexts removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,13 +144,12 @@
|
|||||||
|
|
||||||
- (void)willInsertRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
|
- (void)willInsertRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
|
||||||
{
|
{
|
||||||
for (NSString *kind in _pendingContexts) {
|
[_pendingContexts enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull kind, NSMutableArray<ASIndexedNodeContext *> * _Nonnull contexts, BOOL * _Nonnull stop) {
|
||||||
NSMutableArray<ASIndexedNodeContext *> *contexts = _pendingContexts[kind];
|
|
||||||
|
|
||||||
[self batchLayoutNodesFromContexts:contexts ofKind:kind completion:^(NSArray<ASCellNode *> *nodes, NSArray<NSIndexPath *> *indexPaths) {
|
[self batchLayoutNodesFromContexts:contexts ofKind:kind completion:^(NSArray<ASCellNode *> *nodes, NSArray<NSIndexPath *> *indexPaths) {
|
||||||
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
|
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
|
||||||
}];
|
}];
|
||||||
}
|
}];
|
||||||
|
|
||||||
[_pendingContexts removeAllObjects];
|
[_pendingContexts removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user