Use fromInt() instead of indexing values() as it allocates a new array
Summary: values() create a shallow copy of the underlying array every time as there are no immutable arrays in java. By using fromInt() we avoid this allocation. Reviewed By: pasqualeanatriello Differential Revision: D4494371 fbshipit-source-id: 11cff65114803e185bc67a96da0bf2a2c4a3e6d9
This commit is contained in:
committed by
Facebook Github Bot
parent
30413265c7
commit
d62ca8c518
@@ -211,7 +211,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
private native int jni_YGNodeStyleGetDirection(long nativePointer);
|
||||
@Override
|
||||
public YogaDirection getStyleDirection() {
|
||||
return YogaDirection.values()[jni_YGNodeStyleGetDirection(mNativePointer)];
|
||||
return YogaDirection.fromInt(jni_YGNodeStyleGetDirection(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
|
||||
@@ -223,7 +223,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
private native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
|
||||
@Override
|
||||
public YogaFlexDirection getFlexDirection() {
|
||||
return YogaFlexDirection.values()[jni_YGNodeStyleGetFlexDirection(mNativePointer)];
|
||||
return YogaFlexDirection.fromInt(jni_YGNodeStyleGetFlexDirection(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
|
||||
@@ -235,7 +235,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
private native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
|
||||
@Override
|
||||
public YogaJustify getJustifyContent() {
|
||||
return YogaJustify.values()[jni_YGNodeStyleGetJustifyContent(mNativePointer)];
|
||||
return YogaJustify.fromInt(jni_YGNodeStyleGetJustifyContent(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
|
||||
@@ -247,7 +247,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
private native int jni_YGNodeStyleGetAlignItems(long nativePointer);
|
||||
@Override
|
||||
public YogaAlign getAlignItems() {
|
||||
return YogaAlign.values()[jni_YGNodeStyleGetAlignItems(mNativePointer)];
|
||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignItems(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
|
||||
@@ -259,7 +259,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
private native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
|
||||
@Override
|
||||
public YogaAlign getAlignSelf() {
|
||||
return YogaAlign.values()[jni_YGNodeStyleGetAlignSelf(mNativePointer)];
|
||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignSelf(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
|
||||
@@ -271,7 +271,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
private native int jni_YGNodeStyleGetAlignContent(long nativePointer);
|
||||
@Override
|
||||
public YogaAlign getAlignContent() {
|
||||
return YogaAlign.values()[jni_YGNodeStyleGetAlignContent(mNativePointer)];
|
||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignContent(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
|
||||
@@ -283,7 +283,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
private native int jni_YGNodeStyleGetPositionType(long nativePointer);
|
||||
@Override
|
||||
public YogaPositionType getPositionType() {
|
||||
return YogaPositionType.values()[jni_YGNodeStyleGetPositionType(mNativePointer)];
|
||||
return YogaPositionType.fromInt(jni_YGNodeStyleGetPositionType(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
|
||||
@@ -301,7 +301,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
private native int jni_YGNodeStyleGetOverflow(long nativePointer);
|
||||
@Override
|
||||
public YogaOverflow getOverflow() {
|
||||
return YogaOverflow.values()[jni_YGNodeStyleGetOverflow(mNativePointer)];
|
||||
return YogaOverflow.fromInt(jni_YGNodeStyleGetOverflow(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
|
||||
@@ -623,7 +623,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
|
||||
@Override
|
||||
public YogaDirection getLayoutDirection() {
|
||||
return YogaDirection.values()[mLayoutDirection];
|
||||
return YogaDirection.fromInt(mLayoutDirection);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
|
||||
@@ -647,9 +647,9 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
return mMeasureFunction.measure(
|
||||
this,
|
||||
width,
|
||||
YogaMeasureMode.values()[widthMode],
|
||||
YogaMeasureMode.fromInt(widthMode),
|
||||
height,
|
||||
YogaMeasureMode.values()[heightMode]);
|
||||
YogaMeasureMode.fromInt(heightMode));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
|
||||
|
Reference in New Issue
Block a user