Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layoutAttributesForSupplementaryItemInSection called too often #100

Closed
allright opened this issue Jan 27, 2014 · 6 comments
Closed

layoutAttributesForSupplementaryItemInSection called too often #100

allright opened this issue Jan 27, 2014 · 6 comments

Comments

@allright
Copy link

Have to optimize
JNWCollectionViewFramework:layoutIdentifiersForSupplementaryViewsInRect:(CGRect)rect{
}
to call layoutAttributesForSupplementaryItemInSection only for visible sections
Test case: a table with 1000 sections - may be not smooth.

I will try to fix...

@jwilling
Copy link
Owner

Ah yes, I perform a linear search and get the layout attributes for each supplementary item to see if it intersects the visible rect. This should probably be deferred to the layout as well, as it does for the cells already.

@allright
Copy link
Author

Also I've just figured out that:
recursive call of
JNWCollectionViewLayoutAttributes *nextHeaderAttributes = [self layoutAttributesForSupplementaryItemInSection:sectionIdx + 1 kind:kind];
cause too big call stack.

@allright
Copy link
Author

NSOrderedSet

  • (NSUInteger)indexOfObject:(id)object inSortedRange:(NSRange)range options:(NSBinarySearchingOptions)opts usingComparator:(NSComparator)cmp; // binary search

can replace linear search by binary

@jwilling
Copy link
Owner

@allright I can't assume the layout is going to be linear (in which case a binary search would be fine), so I have to fallback to a linear search. That's why I suggested it be deferred to the layout class, as it's already done in for the cells. I use a binary search already for the cells in the list view.

Do the lag issues go away when you switch off sticky headers? I didn't test the sticky header code with a large number of sections, and that code would be badly optimized in that case. If you have any better ideas for implementation I'm all ears.

@allright
Copy link
Author

I have to dig into the code a little deeper to generate idea...

@jwilling
Copy link
Owner

Closing this issue in favor of #108.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants