Closed astrokin closed 6 years ago
Hi @maxsokolov afaik NO :)
Complexity: O(1) if the collection conforms to RandomAccessCollection; otherwise, O(n), where n is the length of the collection.
public struct Array
: RandomAccessCollection, MutableCollection
@astrokin
the link above is pointing to count
property.
But I may be wrong about O(n). I see that indices
is CountableRange, not an Array.
@maxsokolov my fault. seems miss-reading... i'll add my case in demo project later to demonstrate the case. Please feel free to close this PR
@astrokin I've added simple check here. Thanks for pointing out to the problem!
Hi @astrokin
Sorry for late response. I see that you are using method
indices.contains(index)
I think this is not good for performance reasons. The cost of this operation is O(n) in worst case, and this is going to be called a lot because method
invoke
is calling for many delegate/datasource method for UITableView.