Optimize SEL search efficiency

Summary:
Optimize `SEL` search efficiency, reduced the time complexity from O (n) to O (1).

Not need tests.

- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/1055

Differential Revision: D6839942

Pulled By: rnystrom

fbshipit-source-id: 911755d6f8a4cd79b387423a51b6ea44cc7a2a07
This commit is contained in:
zhongwuzw 2018-01-29 20:28:55 -08:00 committed by Facebook Github Bot
parent 783adf8014
commit 8bccac9a79
2 changed files with 9 additions and 1 deletions

View file

@ -23,6 +23,8 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag
- Added new `transitionDelegate` API to give `IGListSectionController`s control to customize initial and final `UICollectionViewLayoutAttribute`s. Includes automatic integration with `IGListCollectionViewLayout`. Sue Suhan Ma [(26924ec)](https://github.com/Instagram/IGListKit/commit/26924ec3b665d37aeed7e28887e4221a7f3501b1)
- Reordered position of intercepted selector in `IGListAdapterProxy`'s `isInterceptedSelector` method to reduce overall consumption of compare. [zhongwuzw](https://github.com/zhongwu) [(#1055)](https://github.com/Instagram/IGListKit/pull/1055)
### Fixes
- Duplicate objects for initial data source setup filtered out. [Mikhail Vashlyaev](https://github.com/yemodin) [(#993](https://github.com/Instagram/IGListKit/pull/993)

View file

@ -18,10 +18,15 @@
*/
static BOOL isInterceptedSelector(SEL sel) {
return (
// UIScrollViewDelegate
sel == @selector(scrollViewDidScroll:) ||
sel == @selector(scrollViewWillBeginDragging:) ||
sel == @selector(scrollViewDidEndDragging:willDecelerate:) ||
sel == @selector(scrollViewDidEndDecelerating:) ||
// UICollectionViewDelegate
sel == @selector(collectionView:didSelectItemAtIndexPath:) ||
sel == @selector(collectionView:willDisplayCell:forItemAtIndexPath:) ||
sel == @selector(collectionView:didEndDisplayingCell:forItemAtIndexPath:) ||
sel == @selector(collectionView:didSelectItemAtIndexPath:) ||
sel == @selector(collectionView:didHighlightItemAtIndexPath:) ||
sel == @selector(collectionView:didUnhighlightItemAtIndexPath:) ||
// UICollectionViewDelegateFlowLayout
@ -31,6 +36,7 @@ static BOOL isInterceptedSelector(SEL sel) {
sel == @selector(collectionView:layout:minimumLineSpacingForSectionAtIndex:) ||
sel == @selector(collectionView:layout:referenceSizeForFooterInSection:) ||
sel == @selector(collectionView:layout:referenceSizeForHeaderInSection:) ||
sel == @selector(collectionView:layout:referenceSizeForHeaderInSection:) ||
// UIScrollViewDelegate
sel == @selector(scrollViewDidScroll:) ||
sel == @selector(scrollViewWillBeginDragging:) ||