maxsokolov / TableKit

Type-safe declarative table views.
MIT License
706 stars 74 forks source link

fix crash while dynamically delete rows from tableview with animation #75

Closed astrokin closed 6 years ago

maxsokolov commented 6 years ago

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.

astrokin commented 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

developer.apple.com

maxsokolov commented 6 years ago

@astrokin

the link above is pointing to count property.

maxsokolov commented 6 years ago

But I may be wrong about O(n). I see that indices is CountableRange, not an Array.

astrokin commented 6 years ago

@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

maxsokolov commented 6 years ago

@astrokin I've added simple check here. Thanks for pointing out to the problem!