Avoid warning at [IGListAdapter visibleObjects]

Summary: Almost all of the [warnings](https://fburl.com/scuba/errorreporting_instagram_ios_assertions/s2odhkpd) at `[IGListAdapter visibleObjects]` shown the section index is `9223372036854775807`, which is `NSNotFound`. When the section is `NSNotFound`, there is no need to get object though `[self objectAtSection:section];`, instead we should skip all the operations.

Differential Revision: D39294533

fbshipit-source-id: 3e481c76c0a2dd53b219800e590395b067ae2db8
This commit is contained in:
Yaxuan Wang 2022-09-07 10:53:49 -07:00 committed by Facebook GitHub Bot
parent 2414d3cca5
commit cf7f78e28a

View file

@ -603,10 +603,12 @@ typedef struct OffsetRange {
IGAssert(sectionController != nil, @"Section controller nil for cell %@", cell);
if (sectionController != nil) {
const NSInteger section = [self sectionForSectionController:sectionController];
id object = [self objectAtSection:section];
IGAssert(object != nil, @"Object not found for section controller %@ at section %li", sectionController, (long)section);
if (object != nil) {
[visibleObjects addObject:object];
if (section != NSNotFound) {
id object = [self objectAtSection:section];
IGAssert(object != nil, @"Object not found for section controller %@ at section %li", sectionController, (long)section);
if (object != nil) {
[visibleObjects addObject:object];
}
}
}
}