Fabric: Enabling new TextMeasureCache thing for Android

Summary:
Read more about this in D18848583 (where it's implemented for iOS). This diff enables that for Android.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18869823

fbshipit-source-id: ebdc863ec07268119d1cbbb911760532bb28ee04
This commit is contained in:
Valentin Shergin
2019-12-07 22:47:49 -08:00
committed by Facebook Github Bot
parent 0ef0d3167e
commit 36d895ce21
2 changed files with 4 additions and 11 deletions
@@ -29,8 +29,8 @@ Size TextLayoutManager::measure(
auto &attributedString = attributedStringBox.getValue();
return measureCache_.get(
MeasureCacheKey{attributedString, paragraphAttributes, layoutConstraints},
[&](MeasureCacheKey const &key) {
{attributedString, paragraphAttributes, layoutConstraints},
[&](TextMeasureCacheKey const &key) {
return doMeasure(
attributedString, paragraphAttributes, layoutConstraints);
});
@@ -7,14 +7,11 @@
#pragma once
#include <memory>
#include <react/attributedstring/AttributedString.h>
#include <react/attributedstring/AttributedStringBox.h>
#include <react/attributedstring/ParagraphAttributes.h>
#include <react/core/LayoutConstraints.h>
#include <react/textlayoutmanager/TextMeasureCache.h>
#include <react/utils/ContextContainer.h>
#include <react/utils/SimpleThreadSafeCache.h>
namespace facebook {
namespace react {
@@ -52,13 +49,9 @@ class TextLayoutManager {
ParagraphAttributes paragraphAttributes,
LayoutConstraints layoutConstraints) const;
using MeasureCacheKey =
std::tuple<AttributedString, ParagraphAttributes, LayoutConstraints>;
using MeasureCache = SimpleThreadSafeCache<MeasureCacheKey, Size, 256>;
void *self_;
ContextContainer::Shared contextContainer_;
MeasureCache measureCache_{};
TextMeasureCache measureCache_{};
};
} // namespace react