tidev / titanium-sdk

🚀 Native iOS and Android Apps with JavaScript
https://titaniumsdk.com/
Other
2.76k stars 1.21k forks source link

feat(android): optimize referenceTable #13953

Open m1ga opened 11 months ago

m1ga commented 11 months ago

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.