Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Improving speed of layouting #92

Open
wants to merge 1 commit into from

3 participants

@soniccat

I just downloaded your library and started analyze source code. It's a nice written project).
But I found that setSubviewsCacheAsInvalid is called in every layoutSubviews call. I think that it's wrong to clear cache when I scroll by 1 pixel. We should do this only if we have new cells to load.
Am I wrong?

@mwyman

Maybe I'm wrong, but this code is very similar to another performance improvement that was committed then withdrawn a while ago.

While it's useful in speeding up scrolling (I have similar code in a private build), it apparently caused problems for some developers. Not quite sure why my use case isn't giving me the same problems (perhaps because I'm not allowing reordering)...

@soniccat

Hmm it means that I will change the library in different places when I will use it)

@HubOkay

There are something wrong in the editing status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 8, 2012
  1. @soniccat

    Improving speed of layouting

    soniccat authored
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 1 deletion.
  1. +10 −1 GMGridView/GMGridView.m
View
11 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];
Something went wrong with that request. Please try again.