Move the DEBUG uniqueness check outside of for-loop inside IGListAdapter

Summary:
The original DEBUG was put inside a for loop, which caused a quadratic looping while creating bigger and bigger NSSet.

This is very inefficient and I verified that by profiling with 10000 objects in the array and it caused significant amount of CPU. The main thread is pretty much unresponsive.
Closes https://github.com/Instagram/IGListKit/pull/1084

Reviewed By: rnystrom

Differential Revision: D6903043

Pulled By: lorixx

fbshipit-source-id: 311e8a402eb8d5574fce0eabd626a674b6a5e8c5
This commit is contained in:
Zhisheng Huang 2018-02-05 12:21:27 -08:00 committed by Facebook Github Bot
parent 37c798ac78
commit c617b18eb6

View file

@ -621,13 +621,13 @@
}
[sectionControllers addObject:sectionController];
#if DEBUG
IGAssert([NSSet setWithArray:sectionControllers].count == sectionControllers.count,
@"Section controllers array is not filled with unique objects; section controllers are being reused");
#endif
[validObjects addObject:object];
}
#if DEBUG
IGAssert([NSSet setWithArray:sectionControllers].count == sectionControllers.count,
@"Section controllers array is not filled with unique objects; section controllers are being reused");
#endif
// clear the view controller and collection context
IGListSectionControllerPopThread();