titanium-sdk icon indicating copy to clipboard operation
titanium-sdk copied to clipboard

feat(android): optimize referenceTable

Open m1ga opened this issue 1 year ago • 0 comments

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.

m1ga avatar Dec 14 '23 17:12 m1ga