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

Commit 86b669d

Browse files
author
Adlai Holler
authored
Improve TableLayoutController: Simplify, Fix Crash & Improve Perf (#2969)
* Refactor FlowLayoutController -> TableLayoutController * Use most conservative row index path
1 parent f71eba7 commit 86b669d

14 files changed

Lines changed: 253 additions & 392 deletions

AsyncDisplayKit.xcodeproj/project.pbxproj

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@
9595
34EFC7731B701D0700AD841F /* ASAbsoluteLayoutSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED181B17843500DA7C62 /* ASAbsoluteLayoutSpec.h */; settings = {ATTRIBUTES = (Public, ); }; };
9696
34EFC7741B701D0A00AD841F /* ASAbsoluteLayoutSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED191B17843500DA7C62 /* ASAbsoluteLayoutSpec.mm */; };
9797
3C9C128519E616EF00E942A0 /* ASTableViewTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3C9C128419E616EF00E942A0 /* ASTableViewTests.mm */; };
98-
430E7C901B4C23F100697A4C /* ASIndexPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 430E7C8D1B4C23F100697A4C /* ASIndexPath.h */; settings = {ATTRIBUTES = (Public, ); }; };
99-
430E7C921B4C23F100697A4C /* ASIndexPath.m in Sources */ = {isa = PBXBuildFile; fileRef = 430E7C8E1B4C23F100697A4C /* ASIndexPath.m */; };
10098
509E68601B3AED8E009B9150 /* ASScrollDirection.m in Sources */ = {isa = PBXBuildFile; fileRef = 205F0E111B371BD7007741D0 /* ASScrollDirection.m */; };
10199
509E68611B3AEDA0009B9150 /* ASAbstractLayoutController.h in Headers */ = {isa = PBXBuildFile; fileRef = 205F0E171B37339C007741D0 /* ASAbstractLayoutController.h */; settings = {ATTRIBUTES = (Public, ); }; };
102100
509E68621B3AEDA5009B9150 /* ASAbstractLayoutController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 205F0E181B37339C007741D0 /* ASAbstractLayoutController.mm */; };
@@ -262,8 +260,8 @@
262260
B35062161B010EFD0018CF92 /* ASBatchContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 299DA1A81A828D2900162D41 /* ASBatchContext.mm */; };
263261
B35062171B010EFD0018CF92 /* ASDataController.h in Headers */ = {isa = PBXBuildFile; fileRef = 464052191A3F83C40061C0BA /* ASDataController.h */; settings = {ATTRIBUTES = (Public, ); }; };
264262
B35062181B010EFD0018CF92 /* ASDataController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4640521A1A3F83C40061C0BA /* ASDataController.mm */; };
265-
B350621B1B010EFD0018CF92 /* ASFlowLayoutController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4640521B1A3F83C40061C0BA /* ASFlowLayoutController.h */; settings = {ATTRIBUTES = (Public, ); }; };
266-
B350621C1B010EFD0018CF92 /* ASFlowLayoutController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4640521C1A3F83C40061C0BA /* ASFlowLayoutController.mm */; };
263+
B350621B1B010EFD0018CF92 /* ASTableLayoutController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4640521B1A3F83C40061C0BA /* ASTableLayoutController.h */; settings = {ATTRIBUTES = (Private, ); }; };
264+
B350621C1B010EFD0018CF92 /* ASTableLayoutController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4640521C1A3F83C40061C0BA /* ASTableLayoutController.m */; };
267265
B350621D1B010EFD0018CF92 /* ASHighlightOverlayLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 058D09E6195D050800B7D73C /* ASHighlightOverlayLayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
268266
B350621E1B010EFD0018CF92 /* ASHighlightOverlayLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 058D09E7195D050800B7D73C /* ASHighlightOverlayLayer.mm */; };
269267
B350621F1B010EFD0018CF92 /* ASImageProtocols.h in Headers */ = {isa = PBXBuildFile; fileRef = 05F20AA31A15733C00DCA68A /* ASImageProtocols.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -533,12 +531,10 @@
533531
299DA1A81A828D2900162D41 /* ASBatchContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASBatchContext.mm; sourceTree = "<group>"; };
534532
29CDC2E11AAE70D000833CA4 /* ASBasicImageDownloaderContextTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = ASBasicImageDownloaderContextTests.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
535533
3C9C128419E616EF00E942A0 /* ASTableViewTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = ASTableViewTests.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
536-
430E7C8D1B4C23F100697A4C /* ASIndexPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIndexPath.h; sourceTree = "<group>"; };
537-
430E7C8E1B4C23F100697A4C /* ASIndexPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIndexPath.m; sourceTree = "<group>"; };
538534
464052191A3F83C40061C0BA /* ASDataController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = ASDataController.h; sourceTree = "<group>"; };
539535
4640521A1A3F83C40061C0BA /* ASDataController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = ASDataController.mm; sourceTree = "<group>"; };
540-
4640521B1A3F83C40061C0BA /* ASFlowLayoutController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASFlowLayoutController.h; sourceTree = "<group>"; };
541-
4640521C1A3F83C40061C0BA /* ASFlowLayoutController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASFlowLayoutController.mm; sourceTree = "<group>"; };
536+
4640521B1A3F83C40061C0BA /* ASTableLayoutController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASTableLayoutController.h; sourceTree = "<group>"; };
537+
4640521C1A3F83C40061C0BA /* ASTableLayoutController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASTableLayoutController.m; sourceTree = "<group>"; };
542538
4640521D1A3F83C40061C0BA /* ASLayoutController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutController.h; sourceTree = "<group>"; };
543539
683489271D70DE3400327501 /* ASDisplayNode+Deprecated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASDisplayNode+Deprecated.h"; sourceTree = "<group>"; };
544540
68355B2E1CB5799E001D4E68 /* ASImageNode+AnimatedImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "ASImageNode+AnimatedImage.mm"; sourceTree = "<group>"; };
@@ -1062,15 +1058,13 @@
10621058
68C215571DE10D330019C4BC /* ASCollectionViewLayoutInspector.m */,
10631059
205F0E1B1B373A2C007741D0 /* ASCollectionViewLayoutController.h */,
10641060
205F0E1C1B373A2C007741D0 /* ASCollectionViewLayoutController.mm */,
1065-
4640521B1A3F83C40061C0BA /* ASFlowLayoutController.h */,
1066-
4640521C1A3F83C40061C0BA /* ASFlowLayoutController.mm */,
1061+
4640521B1A3F83C40061C0BA /* ASTableLayoutController.h */,
1062+
4640521C1A3F83C40061C0BA /* ASTableLayoutController.m */,
10671063
058D09E6195D050800B7D73C /* ASHighlightOverlayLayer.h */,
10681064
058D09E7195D050800B7D73C /* ASHighlightOverlayLayer.mm */,
10691065
68355B371CB57A5A001D4E68 /* ASImageContainerProtocolCategories.h */,
10701066
68355B381CB57A5A001D4E68 /* ASImageContainerProtocolCategories.m */,
10711067
05F20AA31A15733C00DCA68A /* ASImageProtocols.h */,
1072-
430E7C8D1B4C23F100697A4C /* ASIndexPath.h */,
1073-
430E7C8E1B4C23F100697A4C /* ASIndexPath.m */,
10741068
4640521D1A3F83C40061C0BA /* ASLayoutController.h */,
10751069
292C59991A956527007E5DD6 /* ASLayoutRangeType.h */,
10761070
68EE0DBB1C1B4ED300BA1B99 /* ASMainSerialQueue.h */,
@@ -1437,13 +1431,12 @@
14371431
CC0F88601E4280B800576FED /* _ASCollectionViewCell.h in Headers */,
14381432
B35062001B010EFD0018CF92 /* ASEditableTextNode.h in Headers */,
14391433
680346941CE4052A0009FEB4 /* ASNavigationController.h in Headers */,
1440-
B350621B1B010EFD0018CF92 /* ASFlowLayoutController.h in Headers */,
1434+
B350621B1B010EFD0018CF92 /* ASTableLayoutController.h in Headers */,
14411435
B350621D1B010EFD0018CF92 /* ASHighlightOverlayLayer.h in Headers */,
14421436
C78F7E2B1BF7809800CDEAFC /* ASTableNode.h in Headers */,
14431437
7AB338671C55B3460055FDE8 /* ASRelativeLayoutSpec.h in Headers */,
14441438
B35062021B010EFD0018CF92 /* ASImageNode.h in Headers */,
14451439
B350621F1B010EFD0018CF92 /* ASImageProtocols.h in Headers */,
1446-
430E7C901B4C23F100697A4C /* ASIndexPath.h in Headers */,
14471440
34EFC75F1B701C8600AD841F /* ASInsetLayoutSpec.h in Headers */,
14481441
34EFC7671B701CD900AD841F /* ASLayout.h in Headers */,
14491442
DBDB83951C6E879900D0098C /* ASPagerFlowLayout.h in Headers */,
@@ -1873,7 +1866,7 @@
18731866
B35062011B010EFD0018CF92 /* ASEditableTextNode.mm in Sources */,
18741867
254C6B881BF94F8A003EC431 /* ASTextKitRenderer.mm in Sources */,
18751868
CC3B208C1C3F7A5400798563 /* ASWeakSet.m in Sources */,
1876-
B350621C1B010EFD0018CF92 /* ASFlowLayoutController.mm in Sources */,
1869+
B350621C1B010EFD0018CF92 /* ASTableLayoutController.m in Sources */,
18771870
B350621E1B010EFD0018CF92 /* ASHighlightOverlayLayer.mm in Sources */,
18781871
9CC606651D24DF9E006581A0 /* NSIndexSet+ASHelpers.m in Sources */,
18791872
DE89C17B1DCEB9CC00D49D74 /* ASLayoutSpec+Debug.m in Sources */,
@@ -1883,7 +1876,6 @@
18831876
68355B401CB57A69001D4E68 /* ASImageContainerProtocolCategories.m in Sources */,
18841877
B35062031B010EFD0018CF92 /* ASImageNode.mm in Sources */,
18851878
254C6B821BF94F8A003EC431 /* ASTextKitComponents.mm in Sources */,
1886-
430E7C921B4C23F100697A4C /* ASIndexPath.m in Sources */,
18871879
34EFC7601B701C8B00AD841F /* ASInsetLayoutSpec.mm in Sources */,
18881880
AC6145441D8AFD4F003D62A2 /* ASSection.m in Sources */,
18891881
34EFC75E1B701BF000AD841F /* ASInternalHelpers.m in Sources */,

AsyncDisplayKit/ASTableView.mm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#import <AsyncDisplayKit/ASTableNode.h>
2626
#import <AsyncDisplayKit/ASRangeController.h>
2727
#import <AsyncDisplayKit/ASEqualityHelpers.h>
28+
#import <AsyncDisplayKit/ASTableLayoutController.h>
2829
#import <AsyncDisplayKit/ASTableView+Undeprecated.h>
2930
#import <AsyncDisplayKit/ASBatchContext.h>
3031

@@ -120,7 +121,7 @@ @interface ASTableView () <ASRangeControllerDataSource, ASRangeControllerDelegat
120121
ASTableViewProxy *_proxyDataSource;
121122
ASTableViewProxy *_proxyDelegate;
122123

123-
ASFlowLayoutController *_layoutController;
124+
ASTableLayoutController *_layoutController;
124125

125126
ASRangeController *_rangeController;
126127

@@ -250,7 +251,7 @@ + (Class)dataControllerClass
250251

251252
- (void)configureWithDataControllerClass:(Class)dataControllerClass eventLog:(ASEventLog *)eventLog
252253
{
253-
_layoutController = [[ASFlowLayoutController alloc] initWithScrollOption:ASFlowLayoutDirectionVertical];
254+
_layoutController = [[ASTableLayoutController alloc] initWithTableView:self];
254255

255256
_rangeController = [[ASRangeController alloc] init];
256257
_rangeController.layoutController = _layoutController;
@@ -260,8 +261,6 @@ - (void)configureWithDataControllerClass:(Class)dataControllerClass eventLog:(AS
260261
_dataController = [[dataControllerClass alloc] initWithDataSource:self eventLog:eventLog];
261262
_dataController.delegate = _rangeController;
262263
_dataController.environmentDelegate = self;
263-
264-
_layoutController.dataSource = _dataController;
265264

266265
_leadingScreensForBatching = 2.0;
267266
_batchContext = [[ASBatchContext alloc] init];

AsyncDisplayKit/AsyncDisplayKit+Debug.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//
1212

1313
#import <AsyncDisplayKit/AsyncDisplayKit+Debug.h>
14+
#import <AsyncDisplayKit/ASAbstractLayoutController.h>
1415
#import <AsyncDisplayKit/ASLayout.h>
1516
#import <AsyncDisplayKit/ASWeakSet.h>
1617
#import <AsyncDisplayKit/UIImage+ASConvenience.h>

AsyncDisplayKit/AsyncDisplayKit.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>
8989
#import <AsyncDisplayKit/ASEqualityHelpers.h>
9090
#import <AsyncDisplayKit/ASHighlightOverlayLayer.h>
91-
#import <AsyncDisplayKit/ASIndexPath.h>
9291
#import <AsyncDisplayKit/ASImageContainerProtocolCategories.h>
9392
#import <AsyncDisplayKit/ASLog.h>
9493
#import <AsyncDisplayKit/ASMutableAttributedStringBuilder.h>

AsyncDisplayKit/Details/ASDataController.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#import <UIKit/UIKit.h>
1414
#import <AsyncDisplayKit/ASBlockTypes.h>
1515
#import <AsyncDisplayKit/ASDimension.h>
16-
#import <AsyncDisplayKit/ASFlowLayoutController.h>
1716
#import <AsyncDisplayKit/ASEventLog.h>
1817
#ifdef __cplusplus
1918
#import <vector>
@@ -112,7 +111,7 @@ extern NSString * const ASCollectionInvalidUpdateException;
112111
* will be updated asynchronously. The dataSource must be updated to reflect the changes before these methods has been called.
113112
* For each data updating, the corresponding methods in delegate will be called.
114113
*/
115-
@interface ASDataController : NSObject <ASFlowLayoutControllerDataSource>
114+
@interface ASDataController : NSObject
116115

117116
- (instancetype)initWithDataSource:(id<ASDataControllerSource>)dataSource eventLog:(nullable ASEventLog *)eventLog NS_DESIGNATED_INITIALIZER;
118117

AsyncDisplayKit/Details/ASFlowLayoutController.h

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)