Inspired by Richard Howell's change https://reviews.llvm.org/D109632 we are calling Sema::addMethodToGlobalList
too much when ASTReader::ReadMethodPool
.
Some debugging indicates that comments and assumptions in Sema::addMethodToGlobalList
might not be correct
for a modular case and ObjCMethodList *List
can be longer than it was originally expected. Iterating through
a long list can be expensive and in the worst case it can add O(n)
complexity (that might end up being
multiplied by a length of another list).
So it is worth checking the length of ObjCMethodList
in this method, how it can grow, should we use a different
data structure for this purpose.