mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Turning on clang tidy performance-*
Summary: changelog: [internal] Enable performance related clang tidy rules. Reviewed By: javache Differential Revision: D33350556 fbshipit-source-id: 486446ed0a1ac88af21b691ac6905b4f2359dafc
This commit is contained in:
1 parent
d016766303
commit
681ed402de
34 files changed
+96
-75
No files matched your search
@@ -28,5 +28,17 @@ modernize-use-equals-delete,
|
||||
modernize-use-override,
|
||||
modernize-use-using,
|
||||
modernize-use-transparent-functors,
|
||||
performance-faster-string-find,
|
||||
performance-for-range-copy,
|
||||
performance-implicit-conversion-in-loop,
|
||||
performance-inefficient-algorithm,
|
||||
performance-inefficient-string-concatenation,
|
||||
performance-inefficient-vector-operation,
|
||||
performance-move-const-arg,
|
||||
performance-move-constructor-init,
|
||||
performance-noexcept-move-constructor,
|
||||
performance-type-promotion-in-math-fn,
|
||||
performance-unnecessary-copy-initialization,
|
||||
performance-unnecessary-value-param,
|
||||
'
|
||||
...
|
||||
@@ -1075,7 +1075,7 @@ void LayoutAnimationKeyFrameManager::setLayoutAnimationStatusDelegate(
|
||||
|
||||
void LayoutAnimationKeyFrameManager::setClockNow(
|
||||
std::function<uint64_t()> now) {
|
||||
now_ = now;
|
||||
now_ = std::move(now);
|
||||
}
|
||||
|
||||
void LayoutAnimationKeyFrameManager::enableSkipInvalidatedKeyFrames() {
|
||||
|
||||
@@ -64,7 +64,8 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations(
|
||||
PropsParserContext parserContext{-1, *contextContainer};
|
||||
|
||||
// Create a RuntimeExecutor
|
||||
RuntimeExecutor runtimeExecutor = [](std::function<void(jsi::Runtime &)>) {};
|
||||
RuntimeExecutor runtimeExecutor =
|
||||
[](std::function<void(jsi::Runtime &)> const &) {};
|
||||
|
||||
// Create component descriptor registry for animation driver
|
||||
auto providerRegistry =
|
||||
|
||||
@@ -54,7 +54,7 @@ std::shared_ptr<void> AttributedStringBox::getOpaquePointer() const {
|
||||
}
|
||||
|
||||
AttributedStringBox &AttributedStringBox::operator=(
|
||||
AttributedStringBox &&other) {
|
||||
AttributedStringBox &&other) noexcept {
|
||||
if (this != &other) {
|
||||
mode_ = other.mode_;
|
||||
value_ = std::move(other.value_);
|
||||
|
||||
@@ -43,7 +43,7 @@ class AttributedStringBox final {
|
||||
AttributedStringBox(AttributedStringBox const &other) = default;
|
||||
AttributedStringBox(AttributedStringBox &&other) noexcept;
|
||||
AttributedStringBox &operator=(AttributedStringBox const &other) = default;
|
||||
AttributedStringBox &operator=(AttributedStringBox &&other);
|
||||
AttributedStringBox &operator=(AttributedStringBox &&other) noexcept;
|
||||
|
||||
/*
|
||||
* Getters.
|
||||
|
||||
+2
-1
@@ -46,7 +46,8 @@ void ComponentDescriptorProviderRegistry::setComponentDescriptorProviderRequest(
|
||||
ComponentDescriptorProviderRequest componentDescriptorProviderRequest)
|
||||
const {
|
||||
std::shared_lock<butter::shared_mutex> lock(mutex_);
|
||||
componentDescriptorProviderRequest_ = componentDescriptorProviderRequest;
|
||||
componentDescriptorProviderRequest_ =
|
||||
std::move(componentDescriptorProviderRequest);
|
||||
}
|
||||
|
||||
void ComponentDescriptorProviderRegistry::request(
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ namespace react {
|
||||
|
||||
Size AndroidProgressBarMeasurementsManager::measure(
|
||||
SurfaceId surfaceId,
|
||||
AndroidProgressBarProps props,
|
||||
AndroidProgressBarProps const &props,
|
||||
LayoutConstraints layoutConstraints) const {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ class AndroidProgressBarMeasurementsManager {
|
||||
|
||||
Size measure(
|
||||
SurfaceId surfaceId,
|
||||
AndroidProgressBarProps props,
|
||||
AndroidProgressBarProps const &props,
|
||||
LayoutConstraints layoutConstraints) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -16,10 +16,10 @@ namespace facebook {
|
||||
namespace react {
|
||||
|
||||
static TextAttributes convertRawProp(
|
||||
const PropsParserContext &context,
|
||||
const RawProps &rawProps,
|
||||
const TextAttributes sourceTextAttributes,
|
||||
const TextAttributes defaultTextAttributes) {
|
||||
PropsParserContext const &context,
|
||||
RawProps const &rawProps,
|
||||
TextAttributes const &sourceTextAttributes,
|
||||
TextAttributes const &defaultTextAttributes) {
|
||||
auto textAttributes = TextAttributes{};
|
||||
|
||||
// Color
|
||||
|
||||
+3
-1
@@ -17,6 +17,8 @@
|
||||
#include <react/renderer/core/LayoutContext.h>
|
||||
#include <react/renderer/core/conversions.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace facebook::jni;
|
||||
|
||||
namespace facebook {
|
||||
@@ -91,7 +93,7 @@ AttributedString AndroidTextInputShadowNode::getPlaceholderAttributedString()
|
||||
void AndroidTextInputShadowNode::setTextLayoutManager(
|
||||
SharedTextLayoutManager textLayoutManager) {
|
||||
ensureUnsealed();
|
||||
textLayoutManager_ = textLayoutManager;
|
||||
textLayoutManager_ = std::move(textLayoutManager);
|
||||
}
|
||||
|
||||
AttributedString AndroidTextInputShadowNode::getMostRecentAttributedString()
|
||||
|
||||
-1
@@ -27,7 +27,6 @@ AndroidTextInputState::AndroidTextInputState(
|
||||
float defaultThemePaddingTop,
|
||||
float defaultThemePaddingBottom)
|
||||
: mostRecentEventCount(mostRecentEventCount),
|
||||
cachedAttributedStringId(0),
|
||||
attributedString(std::move(attributedString)),
|
||||
reactTreeAttributedString(std::move(reactTreeAttributedString)),
|
||||
paragraphAttributes(std::move(paragraphAttributes)),
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace react {
|
||||
#ifdef ANDROID
|
||||
TextInputState::TextInputState(
|
||||
TextInputState const &previousState,
|
||||
folly::dynamic data){};
|
||||
folly::dynamic const &data){};
|
||||
|
||||
/*
|
||||
* Empty implementation for Android because it doesn't use this class.
|
||||
|
||||
@@ -57,7 +57,9 @@ class TextInputState final {
|
||||
size_t mostRecentEventCount{0};
|
||||
|
||||
#ifdef ANDROID
|
||||
TextInputState(TextInputState const &previousState, folly::dynamic data);
|
||||
TextInputState(
|
||||
TextInputState const &previousState,
|
||||
folly::dynamic const &data);
|
||||
|
||||
folly::dynamic getDynamic() const;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace facebook {
|
||||
namespace react {
|
||||
|
||||
EventDispatcher::EventDispatcher(
|
||||
EventQueueProcessor eventProcessor,
|
||||
EventQueueProcessor const &eventProcessor,
|
||||
EventBeat::Factory const &synchonousEventBeatFactory,
|
||||
EventBeat::Factory const &asynchonousEventBeatFactory,
|
||||
EventBeat::SharedOwnerBox const &ownerBox)
|
||||
|
||||
@@ -29,7 +29,7 @@ class EventDispatcher {
|
||||
using Weak = std::weak_ptr<EventDispatcher const>;
|
||||
|
||||
EventDispatcher(
|
||||
EventQueueProcessor eventProcessor,
|
||||
EventQueueProcessor const &eventProcessor,
|
||||
EventBeat::Factory const &synchonousEventBeatFactory,
|
||||
EventBeat::Factory const &asynchonousEventBeatFactory,
|
||||
EventBeat::SharedOwnerBox const &ownerBox);
|
||||
|
||||
@@ -203,7 +203,7 @@ Float LayoutableShadowNode::lastBaseline(Size size) const {
|
||||
}
|
||||
|
||||
ShadowNode::Shared LayoutableShadowNode::findNodeAtPoint(
|
||||
ShadowNode::Shared node,
|
||||
ShadowNode::Shared const &node,
|
||||
Point point) {
|
||||
auto layoutableShadowNode =
|
||||
traitCast<const LayoutableShadowNode *>(node.get());
|
||||
|
||||
@@ -133,7 +133,7 @@ class LayoutableShadowNode : public ShadowNode {
|
||||
* parameter.
|
||||
*/
|
||||
static ShadowNode::Shared findNodeAtPoint(
|
||||
ShadowNode::Shared node,
|
||||
ShadowNode::Shared const &node,
|
||||
Point point);
|
||||
|
||||
/*
|
||||
|
||||
@@ -180,7 +180,7 @@ void ShadowNode::sealRecursive() const {
|
||||
|
||||
props_->seal();
|
||||
|
||||
for (auto child : *children_) {
|
||||
for (auto const &child : *children_) {
|
||||
child->sealRecursive();
|
||||
}
|
||||
}
|
||||
@@ -255,8 +255,8 @@ ShadowNodeFamily const &ShadowNode::getFamily() const {
|
||||
|
||||
ShadowNode::Unshared ShadowNode::cloneTree(
|
||||
ShadowNodeFamily const &shadowNodeFamily,
|
||||
std::function<ShadowNode::Unshared(ShadowNode const &oldShadowNode)>
|
||||
callback) const {
|
||||
std::function<ShadowNode::Unshared(ShadowNode const &oldShadowNode)> const
|
||||
&callback) const {
|
||||
auto ancestors = shadowNodeFamily.getAncestors(*this);
|
||||
|
||||
if (ancestors.empty()) {
|
||||
@@ -308,7 +308,7 @@ std::string ShadowNode::getDebugValue() const {
|
||||
SharedDebugStringConvertibleList ShadowNode::getDebugChildren() const {
|
||||
auto debugChildren = SharedDebugStringConvertibleList{};
|
||||
|
||||
for (auto child : *children_) {
|
||||
for (auto const &child : *children_) {
|
||||
auto debugChild =
|
||||
std::dynamic_pointer_cast<const DebugStringConvertible>(child);
|
||||
if (debugChild) {
|
||||
|
||||
@@ -114,8 +114,8 @@ class ShadowNode : public Sealable, public DebugStringConvertible {
|
||||
*/
|
||||
ShadowNode::Unshared cloneTree(
|
||||
ShadowNodeFamily const &shadowNodeFamily,
|
||||
std::function<ShadowNode::Unshared(ShadowNode const &oldShadowNode)>
|
||||
callback) const;
|
||||
std::function<ShadowNode::Unshared(ShadowNode const &oldShadowNode)> const
|
||||
&callback) const;
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ std::string DebugStringConvertible::getDebugChildrenDescription(
|
||||
auto trailing = options.format ? std::string{"\n"} : std::string{""};
|
||||
auto childrenString = std::string{""};
|
||||
|
||||
for (auto child : getDebugChildren()) {
|
||||
for (auto const &child : getDebugChildren()) {
|
||||
if (!child) {
|
||||
continue;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ std::string DebugStringConvertible::getDebugPropsDescription(
|
||||
|
||||
auto propsString = std::string{""};
|
||||
|
||||
for (auto prop : getDebugProps()) {
|
||||
for (auto const &prop : getDebugProps()) {
|
||||
if (!prop) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ SharedColor colorFromComponents(ColorComponents components) {
|
||||
((int)round(components.blue * ratio) & 0xff));
|
||||
}
|
||||
|
||||
ColorComponents colorComponentsFromColor(SharedColor sharedColor) {
|
||||
ColorComponents colorComponentsFromColor(SharedColor const &sharedColor) {
|
||||
float ratio = 255;
|
||||
Color color = *sharedColor;
|
||||
return ColorComponents{
|
||||
|
||||
@@ -61,7 +61,7 @@ class SharedColor {
|
||||
|
||||
bool isColorMeaningful(SharedColor const &color) noexcept;
|
||||
SharedColor colorFromComponents(ColorComponents components);
|
||||
ColorComponents colorComponentsFromColor(SharedColor color);
|
||||
ColorComponents colorComponentsFromColor(SharedColor const &color);
|
||||
|
||||
SharedColor clearColor();
|
||||
SharedColor blackColor();
|
||||
|
||||
@@ -183,7 +183,7 @@ TelemetryController const &MountingCoordinator::getTelemetryController() const {
|
||||
void MountingCoordinator::setMountingOverrideDelegate(
|
||||
std::weak_ptr<MountingOverrideDelegate const> delegate) const {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
mountingOverrideDelegate_ = delegate;
|
||||
mountingOverrideDelegate_ = std::move(delegate);
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
||||
@@ -39,7 +39,7 @@ std::unique_ptr<ShadowTree> ShadowTreeRegistry::remove(
|
||||
|
||||
bool ShadowTreeRegistry::visit(
|
||||
SurfaceId surfaceId,
|
||||
std::function<void(const ShadowTree &shadowTree)> callback) const {
|
||||
std::function<void(const ShadowTree &shadowTree)> const &callback) const {
|
||||
std::shared_lock<butter::shared_mutex> lock(mutex_);
|
||||
|
||||
auto iterator = registry_.find(surfaceId);
|
||||
@@ -53,7 +53,7 @@ bool ShadowTreeRegistry::visit(
|
||||
}
|
||||
|
||||
void ShadowTreeRegistry::enumerate(
|
||||
std::function<void(const ShadowTree &shadowTree)> callback) const {
|
||||
std::function<void(const ShadowTree &shadowTree)> const &callback) const {
|
||||
std::shared_lock<butter::shared_mutex> lock(mutex_);
|
||||
for (auto const &pair : registry_) {
|
||||
callback(*pair.second);
|
||||
|
||||
@@ -50,14 +50,14 @@ class ShadowTreeRegistry final {
|
||||
*/
|
||||
bool visit(
|
||||
SurfaceId surfaceId,
|
||||
std::function<void(const ShadowTree &shadowTree)> callback) const;
|
||||
std::function<void(const ShadowTree &shadowTree)> const &callback) const;
|
||||
|
||||
/*
|
||||
* Enumerates all stored shadow trees.
|
||||
* Can be called from any thread.
|
||||
*/
|
||||
void enumerate(
|
||||
std::function<void(const ShadowTree &shadowTree)> callback) const;
|
||||
std::function<void(const ShadowTree &shadowTree)> const &callback) const;
|
||||
|
||||
private:
|
||||
mutable butter::shared_mutex mutex_;
|
||||
|
||||
@@ -17,7 +17,7 @@ ShadowViewMutation ShadowViewMutation::CreateMutation(ShadowView shadowView) {
|
||||
/* .type = */ Create,
|
||||
/* .parentShadowView = */ {},
|
||||
/* .oldChildShadowView = */ {},
|
||||
/* .newChildShadowView = */ shadowView,
|
||||
/* .newChildShadowView = */ std::move(shadowView),
|
||||
/* .index = */ -1,
|
||||
};
|
||||
}
|
||||
@@ -26,7 +26,7 @@ ShadowViewMutation ShadowViewMutation::DeleteMutation(ShadowView shadowView) {
|
||||
return {
|
||||
/* .type = */ Delete,
|
||||
/* .parentShadowView = */ {},
|
||||
/* .oldChildShadowView = */ shadowView,
|
||||
/* .oldChildShadowView = */ std::move(shadowView),
|
||||
/* .newChildShadowView = */ {},
|
||||
/* .index = */ -1,
|
||||
};
|
||||
@@ -38,9 +38,9 @@ ShadowViewMutation ShadowViewMutation::InsertMutation(
|
||||
int index) {
|
||||
return {
|
||||
/* .type = */ Insert,
|
||||
/* .parentShadowView = */ parentShadowView,
|
||||
/* .parentShadowView = */ std::move(parentShadowView),
|
||||
/* .oldChildShadowView = */ {},
|
||||
/* .newChildShadowView = */ childShadowView,
|
||||
/* .newChildShadowView = */ std::move(childShadowView),
|
||||
/* .index = */ index,
|
||||
};
|
||||
}
|
||||
@@ -51,8 +51,8 @@ ShadowViewMutation ShadowViewMutation::RemoveMutation(
|
||||
int index) {
|
||||
return {
|
||||
/* .type = */ Remove,
|
||||
/* .parentShadowView = */ parentShadowView,
|
||||
/* .oldChildShadowView = */ childShadowView,
|
||||
/* .parentShadowView = */ std::move(parentShadowView),
|
||||
/* .oldChildShadowView = */ std::move(childShadowView),
|
||||
/* .newChildShadowView = */ {},
|
||||
/* .index = */ index,
|
||||
};
|
||||
@@ -64,8 +64,8 @@ ShadowViewMutation ShadowViewMutation::UpdateMutation(
|
||||
return {
|
||||
/* .type = */ Update,
|
||||
/* .parentShadowView = */ {},
|
||||
/* .oldChildShadowView = */ oldChildShadowView,
|
||||
/* .newChildShadowView = */ newChildShadowView,
|
||||
/* .oldChildShadowView = */ std::move(oldChildShadowView),
|
||||
/* .newChildShadowView = */ std::move(newChildShadowView),
|
||||
/* .index = */ -1,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,9 +17,10 @@ TelemetryController::TelemetryController(
|
||||
: mountingCoordinator_(mountingCoordinator) {}
|
||||
|
||||
bool TelemetryController::pullTransaction(
|
||||
std::function<void(MountingTransactionMetadata metadata)> willMount,
|
||||
std::function<void(ShadowViewMutationList const &mutations)> doMount,
|
||||
std::function<void(MountingTransactionMetadata metadata)> didMount) const {
|
||||
std::function<void(MountingTransactionMetadata metadata)> const &willMount,
|
||||
std::function<void(ShadowViewMutationList const &mutations)> const &doMount,
|
||||
std::function<void(MountingTransactionMetadata metadata)> const &didMount)
|
||||
const {
|
||||
auto optional = mountingCoordinator_.pullTransaction();
|
||||
if (!optional.has_value()) {
|
||||
return false;
|
||||
@@ -39,7 +40,7 @@ bool TelemetryController::pullTransaction(
|
||||
willMount({surfaceId, number, telemetry, compoundTelemetry});
|
||||
|
||||
telemetry.willMount();
|
||||
doMount(std::move(transaction.getMutations()));
|
||||
doMount(transaction.getMutations());
|
||||
telemetry.didMount();
|
||||
|
||||
compoundTelemetry.incorporate(telemetry, numberOfMutations);
|
||||
|
||||
@@ -43,9 +43,12 @@ class TelemetryController final {
|
||||
* Calls `MountingCoordinator::pullTransaction()` and aggregates telemetry.
|
||||
*/
|
||||
bool pullTransaction(
|
||||
std::function<void(MountingTransactionMetadata metadata)> willMount,
|
||||
std::function<void(ShadowViewMutationList const &mutations)> doMount,
|
||||
std::function<void(MountingTransactionMetadata metadata)> didMount) const;
|
||||
std::function<void(MountingTransactionMetadata metadata)> const
|
||||
&willMount,
|
||||
std::function<void(ShadowViewMutationList const &mutations)> const
|
||||
&doMount,
|
||||
std::function<void(MountingTransactionMetadata metadata)> const &didMount)
|
||||
const;
|
||||
|
||||
private:
|
||||
MountingCoordinator const &mountingCoordinator_;
|
||||
|
||||
@@ -43,7 +43,7 @@ static SharedViewProps nonFlattenedDefaultProps(
|
||||
static ShadowNode::Shared makeNode(
|
||||
ComponentDescriptor const &componentDescriptor,
|
||||
int tag,
|
||||
ShadowNode::ListOfShared children,
|
||||
const ShadowNode::ListOfShared &children,
|
||||
bool flattened = false) {
|
||||
auto props = flattened ? generateDefaultProps(componentDescriptor)
|
||||
: nonFlattenedDefaultProps(componentDescriptor);
|
||||
|
||||
@@ -153,7 +153,7 @@ class StackingContextTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
void mutateViewShadowNodeProps_(
|
||||
std::shared_ptr<ViewShadowNode> node,
|
||||
std::shared_ptr<ViewShadowNode> const &node,
|
||||
std::function<void(ViewProps &props)> callback) {
|
||||
rootShadowNode_ =
|
||||
std::static_pointer_cast<RootShadowNode>(rootShadowNode_->cloneTree(
|
||||
@@ -165,7 +165,7 @@ class StackingContextTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
void testViewTree_(
|
||||
std::function<void(StubViewTree const &viewTree)> callback) {
|
||||
std::function<void(StubViewTree const &viewTree)> const &callback) {
|
||||
rootShadowNode_->layoutIfNeeded();
|
||||
|
||||
callback(buildStubViewTreeUsingDifferentiator(*rootShadowNode_));
|
||||
|
||||
@@ -39,7 +39,7 @@ SharedShadowNode UITemplateProcessor::runCommand(
|
||||
std::vector<folly::dynamic> ®isters,
|
||||
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
||||
const NativeModuleRegistry &nativeModuleRegistry,
|
||||
const std::shared_ptr<const ReactNativeConfig> reactNativeConfig) {
|
||||
std::shared_ptr<const ReactNativeConfig> const &reactNativeConfig) {
|
||||
const std::string &opcode = command[0].asString();
|
||||
const int tagOffset = 420000;
|
||||
// TODO: change to integer codes and a switch statement
|
||||
@@ -106,7 +106,7 @@ SharedShadowNode UITemplateProcessor::buildShadowTree(
|
||||
const folly::dynamic ¶ms,
|
||||
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
||||
const NativeModuleRegistry &nativeModuleRegistry,
|
||||
const std::shared_ptr<const ReactNativeConfig> reactNativeConfig) {
|
||||
std::shared_ptr<const ReactNativeConfig> const &reactNativeConfig) {
|
||||
if (DEBUG_FLY) {
|
||||
LOG(INFO)
|
||||
<< "(strt) UITemplateProcessor inject hardcoded 'server rendered' view tree";
|
||||
|
||||
@@ -50,7 +50,7 @@ class UITemplateProcessor {
|
||||
const folly::dynamic ¶ms,
|
||||
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
||||
const NativeModuleRegistry &nativeModuleRegistry,
|
||||
const std::shared_ptr<const ReactNativeConfig> reactNativeConfig);
|
||||
std::shared_ptr<const ReactNativeConfig> const &reactNativeConfig);
|
||||
|
||||
private:
|
||||
static ShadowNode::Shared runCommand(
|
||||
@@ -60,7 +60,7 @@ class UITemplateProcessor {
|
||||
std::vector<folly::dynamic> ®isters,
|
||||
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
||||
const NativeModuleRegistry &nativeModuleRegistry,
|
||||
const std::shared_ptr<const ReactNativeConfig> reactNativeConfig);
|
||||
std::shared_ptr<const ReactNativeConfig> const &reactNativeConfig);
|
||||
};
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
+11
-11
@@ -27,7 +27,7 @@ void *TextLayoutManager::getNativeTextLayoutManager() const {
|
||||
}
|
||||
|
||||
TextMeasurement TextLayoutManager::measure(
|
||||
AttributedStringBox attributedStringBox,
|
||||
AttributedStringBox const &attributedStringBox,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
LayoutConstraints layoutConstraints) const {
|
||||
auto &attributedString = attributedStringBox.getValue();
|
||||
@@ -59,7 +59,7 @@ TextMeasurement TextLayoutManager::measure(
|
||||
|
||||
TextMeasurement TextLayoutManager::measureCachedSpannableById(
|
||||
int64_t cacheId,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
LayoutConstraints layoutConstraints) const {
|
||||
auto env = Environment::current();
|
||||
auto attachmentPositions = env->NewFloatArray(0);
|
||||
@@ -93,8 +93,8 @@ TextMeasurement TextLayoutManager::measureCachedSpannableById(
|
||||
}
|
||||
|
||||
LinesMeasurements TextLayoutManager::measureLines(
|
||||
AttributedString attributedString,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
AttributedString const &attributedString,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
Size size) const {
|
||||
if (mapBufferSerializationEnabled_) {
|
||||
return measureLinesMapBuffer(attributedString, paragraphAttributes, size);
|
||||
@@ -147,8 +147,8 @@ LinesMeasurements TextLayoutManager::measureLines(
|
||||
}
|
||||
|
||||
LinesMeasurements TextLayoutManager::measureLinesMapBuffer(
|
||||
AttributedString attributedString,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
AttributedString const &attributedString,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
Size size) const {
|
||||
const jni::global_ref<jobject> &fabricUIManager =
|
||||
contextContainer_->at<jni::global_ref<jobject>>("FabricUIManager");
|
||||
@@ -189,12 +189,12 @@ LinesMeasurements TextLayoutManager::measureLinesMapBuffer(
|
||||
|
||||
TextMeasurement TextLayoutManager::doMeasure(
|
||||
AttributedString attributedString,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
LayoutConstraints layoutConstraints) const {
|
||||
layoutConstraints.maximumSize.height = std::numeric_limits<Float>::infinity();
|
||||
|
||||
int attachmentsCount = 0;
|
||||
for (auto fragment : attributedString.getFragments()) {
|
||||
for (auto const &fragment : attributedString.getFragments()) {
|
||||
if (fragment.isAttachment()) {
|
||||
attachmentsCount++;
|
||||
}
|
||||
@@ -253,12 +253,12 @@ TextMeasurement TextLayoutManager::doMeasure(
|
||||
|
||||
TextMeasurement TextLayoutManager::doMeasureMapBuffer(
|
||||
AttributedString attributedString,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
LayoutConstraints layoutConstraints) const {
|
||||
layoutConstraints.maximumSize.height = std::numeric_limits<Float>::infinity();
|
||||
|
||||
int attachmentsCount = 0;
|
||||
for (auto fragment : attributedString.getFragments()) {
|
||||
for (auto const &fragment : attributedString.getFragments()) {
|
||||
if (fragment.isAttachment()) {
|
||||
attachmentsCount++;
|
||||
}
|
||||
@@ -290,7 +290,7 @@ TextMeasurement TextLayoutManager::doMeasureMapBuffer(
|
||||
auto attachments = TextMeasurement::Attachments{};
|
||||
if (attachmentsCount > 0) {
|
||||
int attachmentIndex = 0;
|
||||
for (auto fragment : attributedString.getFragments()) {
|
||||
for (const auto &fragment : attributedString.getFragments()) {
|
||||
if (fragment.isAttachment()) {
|
||||
float top = attachmentData[attachmentIndex * 2];
|
||||
float left = attachmentData[attachmentIndex * 2 + 1];
|
||||
|
||||
+8
-8
@@ -42,7 +42,7 @@ class TextLayoutManager {
|
||||
* Measures `attributedString` using native text rendering infrastructure.
|
||||
*/
|
||||
TextMeasurement measure(
|
||||
AttributedStringBox attributedStringBox,
|
||||
AttributedStringBox const &attributedStringBox,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
LayoutConstraints layoutConstraints) const;
|
||||
|
||||
@@ -52,7 +52,7 @@ class TextLayoutManager {
|
||||
*/
|
||||
TextMeasurement measureCachedSpannableById(
|
||||
int64_t cacheId,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
LayoutConstraints layoutConstraints) const;
|
||||
|
||||
/*
|
||||
@@ -60,8 +60,8 @@ class TextLayoutManager {
|
||||
* infrastructure.
|
||||
*/
|
||||
LinesMeasurements measureLines(
|
||||
AttributedString attributedString,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
AttributedString const &attributedString,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
Size size) const;
|
||||
|
||||
/*
|
||||
@@ -73,17 +73,17 @@ class TextLayoutManager {
|
||||
private:
|
||||
TextMeasurement doMeasure(
|
||||
AttributedString attributedString,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
LayoutConstraints layoutConstraints) const;
|
||||
|
||||
TextMeasurement doMeasureMapBuffer(
|
||||
AttributedString attributedString,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
LayoutConstraints layoutConstraints) const;
|
||||
|
||||
LinesMeasurements measureLinesMapBuffer(
|
||||
AttributedString attributedString,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
AttributedString const &attributedString,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
Size size) const;
|
||||
|
||||
void *self_;
|
||||
|
||||
Reference in new issue
Block a user