mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-22 16:58:23 +00:00
Default to using display handler for improved scroll perf
Summary: After experimenting with scroll performance gains, default `IGListAdapter` behavior to use the faster means of collecting visible section controllers. Reviewed By: maxoll Differential Revision: D8543686 fbshipit-source-id: e33a78c0f1d4f208705ff5d490ab032eb6c36e70
This commit is contained in:
parent
a7d720d007
commit
985bf48ce0
3 changed files with 0 additions and 59 deletions
|
|
@ -20,8 +20,6 @@ typedef NS_OPTIONS (NSInteger, IGListExperiment) {
|
|||
IGListExperimentBackgroundDiffing = 1 << 2,
|
||||
/// Test fallback to reloadData when "too many" update operations.
|
||||
IGListExperimentReloadDataFallback = 1 << 3,
|
||||
/// Test a faster way to return visible section controllers.
|
||||
IGListExperimentFasterVisibleSectionController = 1 << 4,
|
||||
/// Test deduping item-level updates.
|
||||
IGListExperimentDedupeItemUpdates = 1 << 5,
|
||||
/// Test deferring object creation until just before diffing.
|
||||
|
|
|
|||
|
|
@ -507,28 +507,6 @@
|
|||
|
||||
- (NSArray<IGListSectionController *> *)visibleSectionControllers {
|
||||
IGAssertMainThread();
|
||||
if (IGListExperimentEnabled(self.experiments, IGListExperimentFasterVisibleSectionController)) {
|
||||
return [self _visibleSectionControllersFromDisplayHandler];
|
||||
} else {
|
||||
return [self _visibleSectionControllersFromLayoutAttributes];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray<IGListSectionController *> *)_visibleSectionControllersFromLayoutAttributes {
|
||||
NSMutableSet *visibleSectionControllers = [NSMutableSet new];
|
||||
NSArray<UICollectionViewLayoutAttributes *> *attributes =
|
||||
[self.collectionView.collectionViewLayout layoutAttributesForElementsInRect:self.collectionView.bounds];
|
||||
for (UICollectionViewLayoutAttributes* attribute in attributes) {
|
||||
IGListSectionController *sectionController = [self sectionControllerForSection:attribute.indexPath.section];
|
||||
IGAssert(sectionController != nil, @"Section controller nil for cell in section %ld", (long)attribute.indexPath.section);
|
||||
if (sectionController) {
|
||||
[visibleSectionControllers addObject:sectionController];
|
||||
}
|
||||
}
|
||||
return [visibleSectionControllers allObjects];
|
||||
}
|
||||
|
||||
- (NSArray<IGListSectionController *> *)_visibleSectionControllersFromDisplayHandler {
|
||||
return [[self.displayHandler visibleListSections] allObjects];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -271,22 +271,6 @@
|
|||
XCTAssertTrue([visibleSectionControllers containsObject:[self.adapter sectionControllerForObject:@4]]);
|
||||
}
|
||||
|
||||
- (void)test_whenCellsExtendBeyondBounds_withFasterExperiment_thatVisibleSectionControllersAreLimited {
|
||||
// add experiment
|
||||
self.adapter.experiments |= IGListExperimentFasterVisibleSectionController;
|
||||
// # of items for each object == [item integerValue], so @2 has 2 items (cells)
|
||||
self.dataSource.objects = @[@1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12];
|
||||
[self.adapter reloadDataWithCompletion:nil];
|
||||
XCTAssertEqual([self.collectionView numberOfSections], 12);
|
||||
NSArray *visibleSectionControllers = [self.adapter visibleSectionControllers];
|
||||
// UIWindow is 100x100, each cell is 100x10 so should have the following section/cell count: 1 + 2 + 3 + 4 = 10 (100 tall)
|
||||
XCTAssertEqual(visibleSectionControllers.count, 4);
|
||||
XCTAssertTrue([visibleSectionControllers containsObject:[self.adapter sectionControllerForObject:@1]]);
|
||||
XCTAssertTrue([visibleSectionControllers containsObject:[self.adapter sectionControllerForObject:@2]]);
|
||||
XCTAssertTrue([visibleSectionControllers containsObject:[self.adapter sectionControllerForObject:@3]]);
|
||||
XCTAssertTrue([visibleSectionControllers containsObject:[self.adapter sectionControllerForObject:@4]]);
|
||||
}
|
||||
|
||||
- (void) test_withEmptySectionPlusFooter_thatVisibleSectionControllersAreCorrect {
|
||||
self.dataSource.objects = @[@0];
|
||||
[self.adapter reloadDataWithCompletion:nil];
|
||||
|
|
@ -304,25 +288,6 @@
|
|||
XCTAssertTrue(visibleSectionControllers.firstObject.supplementaryViewSource == supplementarySource);
|
||||
}
|
||||
|
||||
- (void) test_withEmptySectionPlusFooter_withFasterExperiment_thatVisibleSectionControllersAreCorrect {
|
||||
// add experiment
|
||||
self.adapter.experiments |= IGListExperimentFasterVisibleSectionController;
|
||||
self.dataSource.objects = @[@0];
|
||||
[self.adapter reloadDataWithCompletion:nil];
|
||||
IGTestSupplementarySource *supplementarySource = [IGTestSupplementarySource new];
|
||||
supplementarySource.dequeueFromNib = YES;
|
||||
supplementarySource.collectionContext = self.adapter;
|
||||
supplementarySource.supportedElementKinds = @[UICollectionElementKindSectionFooter];
|
||||
IGListSectionController *controller = [self.adapter sectionControllerForObject:@0];
|
||||
controller.supplementaryViewSource = supplementarySource;
|
||||
supplementarySource.sectionController = controller;
|
||||
[self.adapter performUpdatesAnimated:NO completion:nil];
|
||||
NSArray<IGListSectionController *> *visibleSectionControllers = [self.adapter visibleSectionControllers];
|
||||
|
||||
XCTAssertTrue([visibleSectionControllers count] == 1);
|
||||
XCTAssertTrue(visibleSectionControllers.firstObject.supplementaryViewSource == supplementarySource);
|
||||
}
|
||||
|
||||
- (void)test_whenCellsExtendBeyondBounds_thatVisibleCellsExistForSectionControllers {
|
||||
self.dataSource.objects = @[@2, @3, @4, @5, @6];
|
||||
[self.adapter reloadDataWithCompletion:nil];
|
||||
|
|
|
|||
Loading…
Reference in a new issue