Simplify the code and use _itemCountIsZero (#1400)

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
This commit is contained in:
Zhisheng Huang 2019-11-25 21:27:42 -08:00 committed by Facebook Github Bot
parent 3539ab687b
commit da4a5bbf25

View file

@ -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 {