From da4a5bbf2550ecb61d24d7a469c961503ed3b1ed Mon Sep 17 00:00:00 2001 From: Zhisheng Huang Date: Mon, 25 Nov 2019 21:27:42 -0800 Subject: [PATCH] Simplify the code and use `_itemCountIsZero` (#1400) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: …uld show empty view ## Changes in this pull request Basically we can use the existing _itemCountIsZero like all the other usage, and it's faster since it stopped early, compared to before we loop through all the sectionController.numberOfItems and sum up. ### Checklist - [x] All tests pass. Demo project builds and runs. - [ ] I added tests, an experiment, or detailed why my change isn't tested. - [ ] 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) Pull Request resolved: https://github.com/Instagram/IGListKit/pull/1400 Differential Revision: D18687637 Pulled By: lorixx fbshipit-source-id: bcdc57ba43b86cd0ed639ffaab9ae0493fd2f844 --- Source/IGListKit/IGListAdapter.m | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Source/IGListKit/IGListAdapter.m b/Source/IGListKit/IGListAdapter.m index 328789f2..b12e9d2d 100644 --- a/Source/IGListKit/IGListAdapter.m +++ b/Source/IGListKit/IGListAdapter.m @@ -660,12 +660,7 @@ [[map sectionControllerForObject:object] didUpdateToObject:object]; } - NSInteger itemCount = 0; - for (IGListSectionController *sectionController in sectionControllers) { - itemCount += [sectionController numberOfItems]; - } - - [self _updateBackgroundViewShouldHide:itemCount > 0]; + [self _updateBackgroundViewShouldHide:![self _itemCountIsZero]]; } - (void)_updateBackgroundViewShouldHide:(BOOL)shouldHide {