From f8261bbe512019398d4ccd2a18b8ff9dd030739d Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 25 Feb 2021 10:06:56 -0800 Subject: [PATCH] Don't pass LayoutDirection from Cxx to IntBufferBatchMountItem Summary: I thought we'd need LayoutDirection on the platform at some point, but it turns out we never use it, and don't seem to need it since components just query via `I18nUtil` one time, and it's expected that apps restart if language changes and we need to switch between LTR and RTL. So, it seems like we'll not have any need for this on the platform at any point. And we can save a byte per layout instruction now. Huzzah! Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26660908 fbshipit-source-id: 54c7d132f5fa260a93fc7f09f7cf63059d52ed1f --- .../java/com/facebook/react/fabric/jni/Binding.cpp | 11 ++++------- .../mounting/mountitems/IntBufferBatchMountItem.java | 5 +---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index 9e367641098..afa2ede1e09 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -105,7 +105,7 @@ static inline int getIntBufferSizeForType(CppMountItem::Type mountItemType) { } else if (mountItemType == CppMountItem::Type::UpdatePadding) { return 5; // tag, top, left, bottom, right } else if (mountItemType == CppMountItem::Type::UpdateLayout) { - return 7; // tag, x, y, w, h, layoutDirection, DisplayType + return 6; // tag, x, y, w, h, DisplayType } else if (mountItemType == CppMountItem::Type::UpdateEventEmitter) { return 1; // tag } else { @@ -958,8 +958,6 @@ void Binding::schedulerDidFinishTransaction( int y = round(scale(frame.origin.y, pointScaleFactor)); int w = round(scale(frame.size.width, pointScaleFactor)); int h = round(scale(frame.size.height, pointScaleFactor)); - int layoutDirection = - toInt(mountItem.newChildShadowView.layoutMetrics.layoutDirection); int displayType = toInt(mountItem.newChildShadowView.layoutMetrics.displayType); @@ -968,10 +966,9 @@ void Binding::schedulerDidFinishTransaction( temp[2] = y; temp[3] = w; temp[4] = h; - temp[5] = layoutDirection; - temp[6] = displayType; - env->SetIntArrayRegion(intBufferArray, intBufferPosition, 7, temp); - intBufferPosition += 7; + temp[5] = displayType; + env->SetIntArrayRegion(intBufferArray, intBufferPosition, 6, temp); + intBufferPosition += 6; } } if (cppUpdateEventEmitterMountItems.size() > 0) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java index 311a08143ea..d6d3a0f9c2b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java @@ -161,8 +161,6 @@ public class IntBufferBatchMountItem implements MountItem { int y = mIntBuffer[i++]; int width = mIntBuffer[i++]; int height = mIntBuffer[i++]; - // The final buffer, layoutDirection, seems unused? - i++; int displayType = mIntBuffer[i++]; surfaceMountingManager.updateLayout(reactTag, x, y, width, height, displayType); @@ -232,8 +230,7 @@ public class IntBufferBatchMountItem implements MountItem { } else if (type == INSTRUCTION_UPDATE_LAYOUT) { s.append( String.format( - "UPDATE LAYOUT [%d]: x:%d y:%d w:%d h:%d layoutDirection:%d displayType:%d\n", - mIntBuffer[i++], + "UPDATE LAYOUT [%d]: x:%d y:%d w:%d h:%d displayType:%d\n", mIntBuffer[i++], mIntBuffer[i++], mIntBuffer[i++],