Skip to content

Commit

Permalink
Add feature flag to enable / disable SpannableCache in TextLayoutMana…
Browse files Browse the repository at this point in the history
…gerMapBuffer

Summary:
Quick diff to add feature flag to enable / disable SpannableCache in TextLayoutManagerMapBuffer

changelog: [internal] internal

Reviewed By: genkikondo

Differential Revision: D36498646

fbshipit-source-id: 4cabb75441ddbafeff65f3e9b2df6a38431a996a
  • Loading branch information
mdvacca authored and facebook-github-bot committed May 25, 2022
1 parent 089ff45 commit d315e9c
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.common.mapbuffer.MapBuffer;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.yoga.YogaConstants;
import com.facebook.yoga.YogaMeasureMode;
Expand Down Expand Up @@ -205,19 +206,25 @@ public static Spannable getOrCreateSpannableForText(

Spannable preparedSpannableText;

synchronized (sSpannableCacheLock) {
preparedSpannableText = sSpannableCache.get(attributedString);
if (preparedSpannableText != null) {
return preparedSpannableText;
if (ReactFeatureFlags.enableSpannableCache) {
synchronized (sSpannableCacheLock) {
preparedSpannableText = sSpannableCache.get(attributedString);
if (preparedSpannableText != null) {
return preparedSpannableText;
}
}
}

preparedSpannableText =
createSpannableFromAttributedString(
context, attributedString, reactTextViewManagerCallback);
preparedSpannableText =
createSpannableFromAttributedString(
context, attributedString, reactTextViewManagerCallback);

synchronized (sSpannableCacheLock) {
sSpannableCache.put(attributedString, preparedSpannableText);
synchronized (sSpannableCacheLock) {
sSpannableCache.put(attributedString, preparedSpannableText);
}
} else {
preparedSpannableText =
createSpannableFromAttributedString(
context, attributedString, reactTextViewManagerCallback);
}

return preparedSpannableText;
Expand Down

0 comments on commit d315e9c

Please sign in to comment.