diff --git a/ReactCommon/react/renderer/.clang-tidy b/ReactCommon/react/renderer/.clang-tidy index 62622e7a2e1..f413d1fc858 100644 --- a/ReactCommon/react/renderer/.clang-tidy +++ b/ReactCommon/react/renderer/.clang-tidy @@ -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, ' ... diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index ce50fcdfc71..dc815408e8c 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -1075,7 +1075,7 @@ void LayoutAnimationKeyFrameManager::setLayoutAnimationStatusDelegate( void LayoutAnimationKeyFrameManager::setClockNow( std::function now) { - now_ = now; + now_ = std::move(now); } void LayoutAnimationKeyFrameManager::enableSkipInvalidatedKeyFrames() { diff --git a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp index 2a1a7f6591d..e5eef16ba07 100644 --- a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp +++ b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp @@ -64,7 +64,8 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( PropsParserContext parserContext{-1, *contextContainer}; // Create a RuntimeExecutor - RuntimeExecutor runtimeExecutor = [](std::function) {}; + RuntimeExecutor runtimeExecutor = + [](std::function const &) {}; // Create component descriptor registry for animation driver auto providerRegistry = diff --git a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp index 6022931c18e..d644a5164d3 100644 --- a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp +++ b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp @@ -54,7 +54,7 @@ std::shared_ptr AttributedStringBox::getOpaquePointer() const { } AttributedStringBox &AttributedStringBox::operator=( - AttributedStringBox &&other) { + AttributedStringBox &&other) noexcept { if (this != &other) { mode_ = other.mode_; value_ = std::move(other.value_); diff --git a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h index 720c270fc1d..770386aef31 100644 --- a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h +++ b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h @@ -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. diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp index 867a67ed31b..965c7d409fa 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp @@ -46,7 +46,8 @@ void ComponentDescriptorProviderRegistry::setComponentDescriptorProviderRequest( ComponentDescriptorProviderRequest componentDescriptorProviderRequest) const { std::shared_lock lock(mutex_); - componentDescriptorProviderRequest_ = componentDescriptorProviderRequest; + componentDescriptorProviderRequest_ = + std::move(componentDescriptorProviderRequest); } void ComponentDescriptorProviderRegistry::request( diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.cpp b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.cpp index e1a06feda69..71ce1f60798 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.cpp +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.cpp @@ -18,7 +18,7 @@ namespace react { Size AndroidProgressBarMeasurementsManager::measure( SurfaceId surfaceId, - AndroidProgressBarProps props, + AndroidProgressBarProps const &props, LayoutConstraints layoutConstraints) const { { std::lock_guard lock(mutex_); diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.h b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.h index bbd3e08e47f..7755ed37161 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.h +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.h @@ -24,7 +24,7 @@ class AndroidProgressBarMeasurementsManager { Size measure( SurfaceId surfaceId, - AndroidProgressBarProps props, + AndroidProgressBarProps const &props, LayoutConstraints layoutConstraints) const; private: diff --git a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp index c4f1f2f97e0..af7d0734ff5 100644 --- a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp +++ b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp @@ -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 diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp index 8f3de52d66e..fa497f2e13a 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp @@ -17,6 +17,8 @@ #include #include +#include + 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() diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.cpp b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.cpp index 60992918741..a2deb59db33 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.cpp +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.cpp @@ -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)), diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp index e79b8cc0976..f4930a436e9 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp @@ -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. diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.h index c40f54f62ec..68572c09e21 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.h @@ -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; diff --git a/ReactCommon/react/renderer/core/EventDispatcher.cpp b/ReactCommon/react/renderer/core/EventDispatcher.cpp index 32c037a981f..615390b04d6 100644 --- a/ReactCommon/react/renderer/core/EventDispatcher.cpp +++ b/ReactCommon/react/renderer/core/EventDispatcher.cpp @@ -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) diff --git a/ReactCommon/react/renderer/core/EventDispatcher.h b/ReactCommon/react/renderer/core/EventDispatcher.h index 6556dce932c..9b630b3bf2a 100644 --- a/ReactCommon/react/renderer/core/EventDispatcher.h +++ b/ReactCommon/react/renderer/core/EventDispatcher.h @@ -29,7 +29,7 @@ class EventDispatcher { using Weak = std::weak_ptr; EventDispatcher( - EventQueueProcessor eventProcessor, + EventQueueProcessor const &eventProcessor, EventBeat::Factory const &synchonousEventBeatFactory, EventBeat::Factory const &asynchonousEventBeatFactory, EventBeat::SharedOwnerBox const &ownerBox); diff --git a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp index 9206a821bea..c5684692257 100644 --- a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp @@ -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(node.get()); diff --git a/ReactCommon/react/renderer/core/LayoutableShadowNode.h b/ReactCommon/react/renderer/core/LayoutableShadowNode.h index 9f4f90aae8c..35dd55e7514 100644 --- a/ReactCommon/react/renderer/core/LayoutableShadowNode.h +++ b/ReactCommon/react/renderer/core/LayoutableShadowNode.h @@ -133,7 +133,7 @@ class LayoutableShadowNode : public ShadowNode { * parameter. */ static ShadowNode::Shared findNodeAtPoint( - ShadowNode::Shared node, + ShadowNode::Shared const &node, Point point); /* diff --git a/ReactCommon/react/renderer/core/ShadowNode.cpp b/ReactCommon/react/renderer/core/ShadowNode.cpp index 5284cfe3b97..f0b96309fed 100644 --- a/ReactCommon/react/renderer/core/ShadowNode.cpp +++ b/ReactCommon/react/renderer/core/ShadowNode.cpp @@ -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 - callback) const { + std::function 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(child); if (debugChild) { diff --git a/ReactCommon/react/renderer/core/ShadowNode.h b/ReactCommon/react/renderer/core/ShadowNode.h index bcff13aa24c..eb60957c615 100644 --- a/ReactCommon/react/renderer/core/ShadowNode.h +++ b/ReactCommon/react/renderer/core/ShadowNode.h @@ -114,8 +114,8 @@ class ShadowNode : public Sealable, public DebugStringConvertible { */ ShadowNode::Unshared cloneTree( ShadowNodeFamily const &shadowNodeFamily, - std::function - callback) const; + std::function const + &callback) const; #pragma mark - Getters diff --git a/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp b/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp index 46c89bb4eea..fde19f4163a 100644 --- a/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp +++ b/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp @@ -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; } diff --git a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp index 7d607fa8bd8..02c6bf82d4a 100644 --- a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp +++ b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp @@ -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{ diff --git a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.h b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.h index ef254542cb6..7de09df3adc 100644 --- a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.h +++ b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.h @@ -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(); diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp index 8a7ed1376fb..6546e0c11ad 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp @@ -183,7 +183,7 @@ TelemetryController const &MountingCoordinator::getTelemetryController() const { void MountingCoordinator::setMountingOverrideDelegate( std::weak_ptr delegate) const { std::lock_guard lock(mutex_); - mountingOverrideDelegate_ = delegate; + mountingOverrideDelegate_ = std::move(delegate); } } // namespace react diff --git a/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp b/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp index 2e33baf019c..2b0c6927edf 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp @@ -39,7 +39,7 @@ std::unique_ptr ShadowTreeRegistry::remove( bool ShadowTreeRegistry::visit( SurfaceId surfaceId, - std::function callback) const { + std::function const &callback) const { std::shared_lock lock(mutex_); auto iterator = registry_.find(surfaceId); @@ -53,7 +53,7 @@ bool ShadowTreeRegistry::visit( } void ShadowTreeRegistry::enumerate( - std::function callback) const { + std::function const &callback) const { std::shared_lock lock(mutex_); for (auto const &pair : registry_) { callback(*pair.second); diff --git a/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h b/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h index 950f41b7b13..5e520f96398 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h +++ b/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h @@ -50,14 +50,14 @@ class ShadowTreeRegistry final { */ bool visit( SurfaceId surfaceId, - std::function callback) const; + std::function const &callback) const; /* * Enumerates all stored shadow trees. * Can be called from any thread. */ void enumerate( - std::function callback) const; + std::function const &callback) const; private: mutable butter::shared_mutex mutex_; diff --git a/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp b/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp index 7e32e07c4c0..437f6634dba 100644 --- a/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp @@ -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, }; } diff --git a/ReactCommon/react/renderer/mounting/TelemetryController.cpp b/ReactCommon/react/renderer/mounting/TelemetryController.cpp index f45ca07dcbe..f660768a5cd 100644 --- a/ReactCommon/react/renderer/mounting/TelemetryController.cpp +++ b/ReactCommon/react/renderer/mounting/TelemetryController.cpp @@ -17,9 +17,10 @@ TelemetryController::TelemetryController( : mountingCoordinator_(mountingCoordinator) {} bool TelemetryController::pullTransaction( - std::function willMount, - std::function doMount, - std::function didMount) const { + std::function const &willMount, + std::function const &doMount, + std::function 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); diff --git a/ReactCommon/react/renderer/mounting/TelemetryController.h b/ReactCommon/react/renderer/mounting/TelemetryController.h index effe81fcfa9..8ea445e8f0a 100644 --- a/ReactCommon/react/renderer/mounting/TelemetryController.h +++ b/ReactCommon/react/renderer/mounting/TelemetryController.h @@ -43,9 +43,12 @@ class TelemetryController final { * Calls `MountingCoordinator::pullTransaction()` and aggregates telemetry. */ bool pullTransaction( - std::function willMount, - std::function doMount, - std::function didMount) const; + std::function const + &willMount, + std::function const + &doMount, + std::function const &didMount) + const; private: MountingCoordinator const &mountingCoordinator_; diff --git a/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp b/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp index 8ed7d148d56..cb6868990c7 100644 --- a/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp @@ -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); diff --git a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp index 97d62dbab38..dc315be4276 100644 --- a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp @@ -153,7 +153,7 @@ class StackingContextTest : public ::testing::Test { } void mutateViewShadowNodeProps_( - std::shared_ptr node, + std::shared_ptr const &node, std::function callback) { rootShadowNode_ = std::static_pointer_cast(rootShadowNode_->cloneTree( @@ -165,7 +165,7 @@ class StackingContextTest : public ::testing::Test { } void testViewTree_( - std::function callback) { + std::function const &callback) { rootShadowNode_->layoutIfNeeded(); callback(buildStubViewTreeUsingDifferentiator(*rootShadowNode_)); diff --git a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.cpp b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.cpp index 2cdc59bf062..94b2e359084 100644 --- a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.cpp +++ b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.cpp @@ -39,7 +39,7 @@ SharedShadowNode UITemplateProcessor::runCommand( std::vector ®isters, const ComponentDescriptorRegistry &componentDescriptorRegistry, const NativeModuleRegistry &nativeModuleRegistry, - const std::shared_ptr reactNativeConfig) { + std::shared_ptr 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 reactNativeConfig) { + std::shared_ptr const &reactNativeConfig) { if (DEBUG_FLY) { LOG(INFO) << "(strt) UITemplateProcessor inject hardcoded 'server rendered' view tree"; diff --git a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h index 3cc3fab52f6..22a88aab527 100644 --- a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h +++ b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h @@ -50,7 +50,7 @@ class UITemplateProcessor { const folly::dynamic ¶ms, const ComponentDescriptorRegistry &componentDescriptorRegistry, const NativeModuleRegistry &nativeModuleRegistry, - const std::shared_ptr reactNativeConfig); + std::shared_ptr const &reactNativeConfig); private: static ShadowNode::Shared runCommand( @@ -60,7 +60,7 @@ class UITemplateProcessor { std::vector ®isters, const ComponentDescriptorRegistry &componentDescriptorRegistry, const NativeModuleRegistry &nativeModuleRegistry, - const std::shared_ptr reactNativeConfig); + std::shared_ptr const &reactNativeConfig); }; } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp index 54e152ece33..abc40602f4e 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp @@ -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 &fabricUIManager = contextContainer_->at>("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::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::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]; diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h index 70faabf312a..e739e8ba07a 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h @@ -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_;