-
Notifications
You must be signed in to change notification settings - Fork 13
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
Optimize code and string allocations #55
Conversation
jsbridge/src/main/kotlin/de/prosiebensat1digital/oasisjsbridge/extensions/PromiseExtension.kt
Show resolved
Hide resolved
.../src/main/kotlin/de/prosiebensat1digital/oasisjsbridge/extensions/XMLHttpRequestExtension.kt
Show resolved
Hide resolved
The re-format (which makes sense) and the move to truth (I am not sure about the benefit here ;)) make it a little bit hard to review the real changes but the optimizations are very welcome additions, thanks a lot for your work! Looks good to me, |
jsbridge/src/androidTest/kotlin/de/prosiebensat1digital/oasisjsbridge/BenchmarkTest.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the good change!
I added Truth because the |
Fair point. Rust std lib uses left/right instead of expected/actual to avoid the issues ;) |
Optimize code and string allocations # Conflicts: # jsbridge/src/main/kotlin/de/prosiebensat1digital/oasisjsbridge/JsBridge.kt # jsbridge/src/main/kotlin/de/prosiebensat1digital/oasisjsbridge/extensions/PromiseExtension.kt # jsbridge/src/main/kotlin/de/prosiebensat1digital/oasisjsbridge/extensions/XMLHttpRequestExtension.kt
…locations Optimize code and string allocations
StringBuilder
to construct json strings instead of keeping N copies of the entire string in memory. This makesJsonObjectWrapper
andPayloadObject
a lot faster and use less memoryBenchmark test on my Pixel 6:
JsonObjectWrapper.collectionToJsonString
, 1000 elements:JsonObjectWrapper.mapToJsonString
, 1000 properties: