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

Commit 2a63868

Browse files
committed
Merge pull request #1102 from knopp/ASRangeControlller-get-index-paths-optimization
[ASRangeController] don't get index paths twice if tuning parameters …
2 parents d708874 + 51e4476 commit 2a63868

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

AsyncDisplayKit/Details/ASRangeControllerBeta.mm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,15 @@ - (void)_updateVisibleNodeIndexPaths
109109
if (ASInterfaceStateIncludesVisible(selfInterfaceState)) {
110110
// If we are already visible, get busy! Better get started on preloading before the user scrolls more...
111111
fetchDataIndexPaths = [_layoutController indexPathsForScrolling:_scrollDirection rangeType:ASLayoutRangeTypeFetchData];
112-
displayIndexPaths = [_layoutController indexPathsForScrolling:_scrollDirection rangeType:ASLayoutRangeTypeDisplay];
112+
113+
ASRangeTuningParameters parametersFetchData = [_layoutController tuningParametersForRangeType:ASLayoutRangeTypeFetchData];
114+
ASRangeTuningParameters parametersDisplay = [_layoutController tuningParametersForRangeType:ASLayoutRangeTypeDisplay];
115+
if (parametersDisplay.leadingBufferScreenfuls == parametersFetchData.leadingBufferScreenfuls &&
116+
parametersDisplay.trailingBufferScreenfuls == parametersFetchData.trailingBufferScreenfuls) {
117+
displayIndexPaths = fetchDataIndexPaths;
118+
} else {
119+
displayIndexPaths = [_layoutController indexPathsForScrolling:_scrollDirection rangeType:ASLayoutRangeTypeDisplay];
120+
}
113121

114122
// Typically the fetchDataIndexPaths will be the largest, and be a superset of the others, though it may be disjoint.
115123
// Because allIndexPaths is an NSMutableOrderedSet, this adds the non-duplicate items /after/ the existing items.

0 commit comments

Comments
 (0)