Create YogaValue instances in Java, not C++

Summary:
@public

Passing primitive data via JNI is more efficient than passing objects.

Here, we avoid creating `YogaValue` (Java) instances via JNI, and rather pass a `long` back to Java. The instance is then created by extracting the necessary bytes on the Java side.

Reviewed By: foghina

Differential Revision: D14576755

fbshipit-source-id: 22d09ad50c3ac6c49b0a797a0dad639ea4829df9
This commit is contained in:
David Aurelio
2019-03-22 10:31:18 -07:00
committed by Facebook Github Bot
parent 5bb2265083
commit ca46c67e9e
6 changed files with 67 additions and 48 deletions

View File

@@ -28,11 +28,3 @@ struct JYogaLogger : public facebook::jni::JavaClass<JYogaLogger> {
facebook::jni::alias_ref<JYogaLogLevel>,
jstring);
};
struct JYogaValue : public facebook::jni::JavaClass<JYogaValue> {
constexpr static auto kJavaDescriptor = "Lcom/facebook/yoga/YogaValue;";
static facebook::jni::local_ref<javaobject> create(YGValue value) {
return newInstance(value.value, static_cast<int>(value.unit));
}
};