mikepenz / FastAdapter

The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
https://mikepenz.dev
Apache License 2.0
3.83k stars 492 forks source link

For discussion - Performance issues on selectExtension.deselect() #1000

Closed RobbWatershed closed 3 years ago

RobbWatershed commented 3 years ago

About this issue

Performance of selectExtension.deselect() is atrocious : users with large collections of items report the app hanging during 20-30s during that sole step of deselecting data.

When calling selectExtension.deselect(selectExtension.getSelections()) instead, FastAdapter only processes actually selected items, and the freeze doesn't happen anymore.

=> Are you certain the use of fastAdapter.recursive when calling deselect() is the best way to go ? Isn't there some kind of optimization that can be done there ?

Details

Checklist

mikepenz commented 3 years ago

@RobbWatershed thank you so much for the issue (and the PR) I hope to be able to come back to it soon. the next 2-3 weeks may be super busy though, so I am sorry in case it's taking me a bit longer to come back to these

RobbWatershed commented 3 years ago

No problem man, take your time, it's not blocking me in any way 😉

mikepenz commented 3 years ago

@RobbWatershed one of the major reasons for the way deselect() works is to really make sure nothing is selected anymore. It does not make assumptions on implementation details (e.g. it will deselect all items) -> for example if sub items can't be selected.

if your usecase does not allow selections in subitems then the second approach would for sure much more fit the requirements.

in the past we had a list keeping track of selections, but ultimately this served to be problematic as it may get out of sync, and ultimately the adapter itself should not necessarily maintain this.

Not sure if this already answers your concern/question?

mikepenz commented 3 years ago

Also congrats to opening the 1000th ticket :D

RobbWatershed commented 3 years ago

if your usecase does not allow selections in subitems then the second approach would for sure much more fit the requirements.

in the past we had a list keeping track of selections, but ultimately this served to be problematic as it may get out of sync, and ultimately the adapter itself should not necessarily maintain this.

That's a perfectly valid answer to me, thanks !

I didn't even think about subitems when considering creating that issue, tbh, as my app doesn't use them.

I'll keep using selectExtension.deselect(selectExtension.getSelections()) for my own needs