From 3633532cdbe4772af620f11009930b6043bcf434 Mon Sep 17 00:00:00 2001 From: Alexey Glushkov Date: Tue, 8 May 2012 18:31:15 +0400 Subject: [PATCH] Improving speed of layouting --- GMGridView/GMGridView.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/GMGridView/GMGridView.m b/GMGridView/GMGridView.m index c362c29..08283ed 100644 --- a/GMGridView/GMGridView.m +++ b/GMGridView/GMGridView.m @@ -1383,7 +1383,16 @@ - (void)loadRequiredItems // calculate new position range self.firstPositionLoaded = self.firstPositionLoaded == GMGV_INVALID_POSITION ? rangeOfPositions.location : MIN(self.firstPositionLoaded, (NSInteger)rangeOfPositions.location); self.lastPositionLoaded = self.lastPositionLoaded == GMGV_INVALID_POSITION ? NSMaxRange(rangeOfPositions) : MAX(self.lastPositionLoaded, (NSInteger)(rangeOfPositions.length + rangeOfPositions.location)); - + + // return if all items was already loaded + if( self.firstPositionLoaded != GMGV_INVALID_POSITION && + self.lastPositionLoaded != GMGV_INVALID_POSITION && + self.firstPositionLoaded == loadedPositionsRange.location && + self.lastPositionLoaded == loadedPositionsRange.location + loadedPositionsRange.length) + { + return; + } + // remove now invisible items [self setSubviewsCacheAsInvalid]; [self cleanupUnseenItems];