mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Cleanup ReactFeatureFlags.enableTextSpannableCache (#44706)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44706 We didn't ship this, and asking around, I don't think mdvacca was looking at this actively (though is on PTO right now). Changelog: [Internal] Reviewed By: rozele Differential Revision: D57913491 fbshipit-source-id: 86afd5a6bb5e7ce6be540f2295aa407134a6d81c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3c31e9dd9f
commit
5fbebb4852
@@ -1961,7 +1961,6 @@ public class com/facebook/react/config/ReactFeatureFlags {
|
||||
public static field enableFabricRenderer Z
|
||||
public static field enableFabricRendererExclusively Z
|
||||
public static field enableRemoveDeleteTreeInstruction Z
|
||||
public static field enableTextSpannableCache Z
|
||||
public static field enableViewRecycling Z
|
||||
public static field excludeYogaFromRawProps Z
|
||||
public static field rejectTurboModulePromiseOnNativeError Z
|
||||
|
||||
-3
@@ -80,9 +80,6 @@ public class ReactFeatureFlags {
|
||||
|
||||
public static boolean dispatchPointerEvents = false;
|
||||
|
||||
/** Feature Flag to enable a cache of Spannable objects used by TextLayoutManager */
|
||||
public static boolean enableTextSpannableCache = false;
|
||||
|
||||
/**
|
||||
* Feature Flag to enable View Recycling. When enabled, individual ViewManagers must still opt-in.
|
||||
*/
|
||||
|
||||
+3
-28
@@ -7,8 +7,6 @@
|
||||
|
||||
package com.facebook.react.views.text;
|
||||
|
||||
import static com.facebook.react.config.ReactFeatureFlags.enableTextSpannableCache;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
@@ -21,7 +19,6 @@ import android.text.StaticLayout;
|
||||
import android.text.TextDirectionHeuristics;
|
||||
import android.text.TextPaint;
|
||||
import android.util.LayoutDirection;
|
||||
import android.util.LruCache;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -33,7 +30,6 @@ import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.common.build.ReactBuildConfig;
|
||||
import com.facebook.react.common.mapbuffer.MapBuffer;
|
||||
import com.facebook.react.common.mapbuffer.ReadableMapBuffer;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
import com.facebook.react.uimanager.ReactAccessibilityDelegate.AccessibilityRole;
|
||||
import com.facebook.react.uimanager.ReactAccessibilityDelegate.Role;
|
||||
@@ -93,23 +89,15 @@ public class TextLayoutManager {
|
||||
// The bug is that unicode emoticons aren't measured properly which causes text to be clipped.
|
||||
private static final TextPaint sTextPaintInstance = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
|
||||
// Specifies the amount of spannable that are stored into the {@link sSpannableCache}.
|
||||
private static final short spannableCacheSize = 10000;
|
||||
|
||||
private static final String INLINE_VIEW_PLACEHOLDER = "0";
|
||||
|
||||
private static final boolean DEFAULT_INCLUDE_FONT_PADDING = true;
|
||||
|
||||
private static final boolean DEFAULT_ADJUST_FONT_SIZE_TO_FIT = false;
|
||||
|
||||
private static final Object sCacheLock = new Object();
|
||||
|
||||
private static final ConcurrentHashMap<Integer, Spannable> sTagToSpannableCache =
|
||||
new ConcurrentHashMap<>();
|
||||
|
||||
private static final LruCache<ReadableMapBuffer, Spannable> sSpannableCache =
|
||||
new LruCache<>(spannableCacheSize);
|
||||
|
||||
public static void setCachedSpannableForTag(int reactTag, @NonNull Spannable sp) {
|
||||
if (ENABLE_MEASURE_LOGGING) {
|
||||
FLog.e(TAG, "Set cached spannable for tag[" + reactTag + "]: " + sp.toString());
|
||||
@@ -314,22 +302,9 @@ public class TextLayoutManager {
|
||||
Integer cacheId = attributedString.getInt(AS_KEY_CACHE_ID);
|
||||
text = sTagToSpannableCache.get(cacheId);
|
||||
} else {
|
||||
if (enableTextSpannableCache && attributedString instanceof ReadableMapBuffer) {
|
||||
ReadableMapBuffer mapBuffer = (ReadableMapBuffer) attributedString;
|
||||
synchronized (sCacheLock) {
|
||||
text = sSpannableCache.get(mapBuffer);
|
||||
if (text == null) {
|
||||
text =
|
||||
createSpannableFromAttributedString(
|
||||
context, attributedString, reactTextViewManagerCallback);
|
||||
sSpannableCache.put(mapBuffer, text);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
text =
|
||||
createSpannableFromAttributedString(
|
||||
context, attributedString, reactTextViewManagerCallback);
|
||||
}
|
||||
text =
|
||||
createSpannableFromAttributedString(
|
||||
context, attributedString, reactTextViewManagerCallback);
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
Reference in New Issue
Block a user