Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

astrokin
Copy link
Contributor

No description provided.

@maxsokolov
Copy link
Owner

maxsokolov commented Mar 12, 2018

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
Copy link
Contributor Author

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
Copy link
Owner

@astrokin

the link above is pointing to count property.

@maxsokolov
Copy link
Owner

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

@astrokin
Copy link
Contributor Author

@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
Copy link
Owner

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

@maxsokolov maxsokolov closed this Mar 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants