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

Reduce allocations in JNI invocations #2206

Merged
merged 4 commits into from
Nov 28, 2020
Merged

Conversation

matteblair
Copy link
Member

@matteblair matteblair commented Nov 15, 2020

While refactoring Tangram's JNI usage for the Android SDK a while ago, I noticed opportunities for avoiding a lot of temporary allocations for objects used exclusively to send data between Java and C++. The general pattern here is that rather than passing a Java object's data as primitives in a list of arguments, we can pass the Java objects into JNI methods and use field accessors to get or set the data directly in C++. This requires a bit more boilerplate code to set up field IDs in C++, but minimizing temporary allocations is important for performance and I think several methods are much easier to read now.

@matteblair matteblair marked this pull request as ready for review November 15, 2020 07:58
@matteblair matteblair merged commit c4b0245 into master Nov 28, 2020
@matteblair matteblair deleted the android-nativemap-2 branch November 28, 2020 01:11
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