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

feat(android): optimize referenceTable #13953

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Dec 14, 2023

While going trough some native Android optimization posts like
https://medium.com/android-news/app-optimization-with-arraymap-sparsearray-in-android-c0b7de22541a
I found one place where we can switch from HashMap to SparseArray

Benefits to use SparseArray over HashMap is:
· More memory efficient by using primitives
· No auto-boxing
· Allocation-free

Drawbacks:
· For large collections, it is slower
· It only available for Android

I've build a large app with it and it still worked without any issue. At the moment I couldn't tell if the memory improved that's why I keep it as a draft for now. Need to do some more testing.

https://youtu.be/ORgucLTtTDI?t=221 gives a pro/cons list when to use it or stay with the HashMap.

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.

1 participant