Enable modernize-pass-by-value clang tidy rule
Summary: changelog: [internal] You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-pass-by-value.html # Isn't it wasteful to copy? Isn't reference more efficient? This rule of thumb is no longer true since C++11 with move semantics. Let's look at some examples. # Option one ``` class TextHolder { public: TextBox(std::string const &text) : text_(text) {} private: std::string text_; }; ``` By using reference here, we prevent the caller from using rvalue to and avoiding copy. Regardless of what the caller passes in, copy always happens. # Option two ``` class TextHolder { public: TextBox(std::string const &text) : text_(text) {} TextBox(std::string &&text) : text_(std::move(text)) {} private: std::string text_; }; ``` Here, we provide two constructors, one for const reference and one for rvalue reference. This gives the caller option to avoid copy. But now we have two constructors, which is not ideal. # Option three (what we do in this diff) ``` class TextHolder { public: TextBox(std::string text) : text_(std::move(text)) {} private: std::string text_; }; ``` Here, the caller has option to avoid copy and we only have single constructor. Reviewed By: fkgozali, JoshuaGross Differential Revision: D33276841 fbshipit-source-id: 619d5123d2e28937b22874650366629f24f20a63
This commit is contained in:
Родитель
70b346fb9c
Коммит
5fa6c5a941
|
@ -12,5 +12,6 @@ modernize-redundant-void-arg,
|
|||
modernize-return-braced-init-list,
|
||||
modernize-use-auto,
|
||||
modernize-make-unique,
|
||||
modernize-pass-by-value,
|
||||
'
|
||||
...
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "LayoutAnimationKeyFrameManager.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include <react/debug/flags.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
@ -96,7 +97,7 @@ LayoutAnimationKeyFrameManager::LayoutAnimationKeyFrameManager(
|
|||
RuntimeExecutor runtimeExecutor,
|
||||
ContextContainer::Shared &contextContainer,
|
||||
LayoutAnimationStatusDelegate *delegate)
|
||||
: runtimeExecutor_(runtimeExecutor),
|
||||
: runtimeExecutor_(std::move(runtimeExecutor)),
|
||||
contextContainer_(contextContainer),
|
||||
layoutAnimationStatusDelegate_(delegate),
|
||||
now_([]() {
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -22,9 +24,10 @@ AttributedStringBox::AttributedStringBox(AttributedString const &value)
|
|||
value_(std::make_shared<AttributedString const>(value)),
|
||||
opaquePointer_({}){};
|
||||
|
||||
AttributedStringBox::AttributedStringBox(
|
||||
std::shared_ptr<void> const &opaquePointer)
|
||||
: mode_(Mode::OpaquePointer), value_({}), opaquePointer_(opaquePointer) {}
|
||||
AttributedStringBox::AttributedStringBox(std::shared_ptr<void> opaquePointer)
|
||||
: mode_(Mode::OpaquePointer),
|
||||
value_({}),
|
||||
opaquePointer_(std::move(opaquePointer)) {}
|
||||
|
||||
AttributedStringBox::AttributedStringBox(AttributedStringBox &&other) noexcept
|
||||
: mode_(other.mode_),
|
||||
|
|
|
@ -35,7 +35,7 @@ class AttributedStringBox final {
|
|||
* Custom explicit constructors.
|
||||
*/
|
||||
explicit AttributedStringBox(AttributedString const &value);
|
||||
explicit AttributedStringBox(std::shared_ptr<void> const &opaquePointer);
|
||||
explicit AttributedStringBox(std::shared_ptr<void> opaquePointer);
|
||||
|
||||
/*
|
||||
* Movable, Copyable, Assignable.
|
||||
|
|
|
@ -14,16 +14,18 @@
|
|||
#include <react/renderer/core/PropsParserContext.h>
|
||||
#include <react/renderer/core/ShadowNodeFragment.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
ComponentDescriptorRegistry::ComponentDescriptorRegistry(
|
||||
ComponentDescriptorParameters const ¶meters,
|
||||
ComponentDescriptorParameters parameters,
|
||||
ComponentDescriptorProviderRegistry const &providerRegistry,
|
||||
ContextContainer::Shared contextContainer)
|
||||
: parameters_(parameters),
|
||||
: parameters_(std::move(parameters)),
|
||||
providerRegistry_(providerRegistry),
|
||||
contextContainer_(contextContainer) {}
|
||||
contextContainer_(std::move(contextContainer)) {}
|
||||
|
||||
void ComponentDescriptorRegistry::add(
|
||||
ComponentDescriptorProvider componentDescriptorProvider) const {
|
||||
|
|
|
@ -37,7 +37,7 @@ class ComponentDescriptorRegistry {
|
|||
* be used later to create `ComponentDescriptor`s.
|
||||
*/
|
||||
ComponentDescriptorRegistry(
|
||||
ComponentDescriptorParameters const ¶meters,
|
||||
ComponentDescriptorParameters parameters,
|
||||
ComponentDescriptorProviderRegistry const &providerRegistry,
|
||||
ContextContainer::Shared contextContainer);
|
||||
|
||||
|
|
|
@ -10,27 +10,29 @@
|
|||
#include <react/renderer/components/text/conversions.h>
|
||||
#include <react/renderer/debug/debugStringConvertibleUtils.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
AndroidTextInputState::AndroidTextInputState(
|
||||
int64_t mostRecentEventCount,
|
||||
AttributedString const &attributedString,
|
||||
AttributedString const &reactTreeAttributedString,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
TextAttributes const &defaultTextAttributes,
|
||||
ShadowView const &defaultParentShadowView,
|
||||
AttributedString attributedString,
|
||||
AttributedString reactTreeAttributedString,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
TextAttributes defaultTextAttributes,
|
||||
ShadowView defaultParentShadowView,
|
||||
float defaultThemePaddingStart,
|
||||
float defaultThemePaddingEnd,
|
||||
float defaultThemePaddingTop,
|
||||
float defaultThemePaddingBottom)
|
||||
: mostRecentEventCount(mostRecentEventCount),
|
||||
cachedAttributedStringId(0),
|
||||
attributedString(attributedString),
|
||||
reactTreeAttributedString(reactTreeAttributedString),
|
||||
paragraphAttributes(paragraphAttributes),
|
||||
defaultTextAttributes(defaultTextAttributes),
|
||||
defaultParentShadowView(defaultParentShadowView),
|
||||
attributedString(std::move(attributedString)),
|
||||
reactTreeAttributedString(std::move(reactTreeAttributedString)),
|
||||
paragraphAttributes(std::move(paragraphAttributes)),
|
||||
defaultTextAttributes(std::move(defaultTextAttributes)),
|
||||
defaultParentShadowView(std::move(defaultParentShadowView)),
|
||||
defaultThemePaddingStart(defaultThemePaddingStart),
|
||||
defaultThemePaddingEnd(defaultThemePaddingEnd),
|
||||
defaultThemePaddingTop(defaultThemePaddingTop),
|
||||
|
|
|
@ -79,11 +79,11 @@ class AndroidTextInputState final {
|
|||
|
||||
AndroidTextInputState(
|
||||
int64_t mostRecentEventCount,
|
||||
AttributedString const &attributedString,
|
||||
AttributedString const &reactTreeAttributedString,
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
TextAttributes const &defaultTextAttributes,
|
||||
ShadowView const &defaultParentShadowView,
|
||||
AttributedString attributedString,
|
||||
AttributedString reactTreeAttributedString,
|
||||
ParagraphAttributes paragraphAttributes,
|
||||
TextAttributes defaultTextAttributes,
|
||||
ShadowView defaultParentShadowView,
|
||||
float defaultThemePaddingStart,
|
||||
float defaultThemePaddingEnd,
|
||||
float defaultThemePaddingTop,
|
||||
|
|
|
@ -7,10 +7,13 @@
|
|||
|
||||
#include "EventBeat.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
EventBeat::EventBeat(SharedOwnerBox const &ownerBox) : ownerBox_(ownerBox) {}
|
||||
EventBeat::EventBeat(SharedOwnerBox ownerBox)
|
||||
: ownerBox_(std::move(ownerBox)) {}
|
||||
|
||||
void EventBeat::request() const {
|
||||
isRequested_ = true;
|
||||
|
|
|
@ -47,7 +47,7 @@ class EventBeat {
|
|||
|
||||
using BeatCallback = std::function<void(jsi::Runtime &runtime)>;
|
||||
|
||||
EventBeat(SharedOwnerBox const &ownerBox);
|
||||
EventBeat(SharedOwnerBox ownerBox);
|
||||
|
||||
virtual ~EventBeat() = default;
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <react/renderer/debug/DebugStringConvertible.h>
|
||||
#include <react/renderer/debug/debugStringConvertibleUtils.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -58,7 +60,7 @@ bool ShadowNode::sameFamily(const ShadowNode &first, const ShadowNode &second) {
|
|||
|
||||
ShadowNode::ShadowNode(
|
||||
ShadowNodeFragment const &fragment,
|
||||
ShadowNodeFamily::Shared const &family,
|
||||
ShadowNodeFamily::Shared family,
|
||||
ShadowNodeTraits traits)
|
||||
:
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
|
@ -70,7 +72,7 @@ ShadowNode::ShadowNode(
|
|||
: emptySharedShadowNodeSharedList()),
|
||||
state_(fragment.state),
|
||||
orderIndex_(0),
|
||||
family_(family),
|
||||
family_(std::move(family)),
|
||||
traits_(traits) {
|
||||
react_native_assert(props_);
|
||||
react_native_assert(children_);
|
||||
|
|
|
@ -80,7 +80,7 @@ class ShadowNode : public Sealable, public DebugStringConvertible {
|
|||
*/
|
||||
ShadowNode(
|
||||
ShadowNodeFragment const &fragment,
|
||||
ShadowNodeFamily::Shared const &family,
|
||||
ShadowNodeFamily::Shared family,
|
||||
ShadowNodeTraits traits);
|
||||
|
||||
/*
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <react/renderer/core/ComponentDescriptor.h>
|
||||
#include <react/renderer/core/State.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -21,7 +23,7 @@ ShadowNodeFamily::ShadowNodeFamily(
|
|||
ShadowNodeFamilyFragment const &fragment,
|
||||
EventDispatcher::Weak eventDispatcher,
|
||||
ComponentDescriptor const &componentDescriptor)
|
||||
: eventDispatcher_(eventDispatcher),
|
||||
: eventDispatcher_(std::move(eventDispatcher)),
|
||||
tag_(fragment.tag),
|
||||
surfaceId_(fragment.surfaceId),
|
||||
eventEmitter_(fragment.eventEmitter),
|
||||
|
|
|
@ -12,16 +12,20 @@
|
|||
#include <react/renderer/core/State.h>
|
||||
#include <react/renderer/core/StateData.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
State::State(StateData::Shared const &data, State const &state)
|
||||
: family_(state.family_), data_(data), revision_(state.revision_ + 1){};
|
||||
State::State(StateData::Shared data, State const &state)
|
||||
: family_(state.family_),
|
||||
data_(std::move(data)),
|
||||
revision_(state.revision_ + 1){};
|
||||
|
||||
State::State(
|
||||
StateData::Shared const &data,
|
||||
ShadowNodeFamily::Shared const &family)
|
||||
: family_(family), data_(data), revision_{State::initialRevisionValue} {};
|
||||
State::State(StateData::Shared data, ShadowNodeFamily::Shared const &family)
|
||||
: family_(family),
|
||||
data_(std::move(data)),
|
||||
revision_{State::initialRevisionValue} {};
|
||||
|
||||
State::Shared State::getMostRecentState() const {
|
||||
auto family = family_.lock();
|
||||
|
|
|
@ -34,9 +34,9 @@ class State {
|
|||
* Constructors are protected to make calling them directly with
|
||||
* type-erasured arguments impossible.
|
||||
*/
|
||||
explicit State(StateData::Shared const &data, State const &state);
|
||||
explicit State(StateData::Shared data, State const &state);
|
||||
explicit State(
|
||||
StateData::Shared const &data,
|
||||
StateData::Shared data,
|
||||
ShadowNodeFamily::Shared const &family);
|
||||
|
||||
public:
|
||||
|
|
|
@ -7,17 +7,22 @@
|
|||
|
||||
#include "DebugStringConvertibleItem.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
|
||||
DebugStringConvertibleItem::DebugStringConvertibleItem(
|
||||
const std::string &name,
|
||||
const std::string &value,
|
||||
const SharedDebugStringConvertibleList &props,
|
||||
const SharedDebugStringConvertibleList &children)
|
||||
: name_(name), value_(value), debugProps_(props), children_(children) {}
|
||||
std::string name,
|
||||
std::string value,
|
||||
SharedDebugStringConvertibleList props,
|
||||
SharedDebugStringConvertibleList children)
|
||||
: name_(std::move(name)),
|
||||
value_(std::move(value)),
|
||||
debugProps_(std::move(props)),
|
||||
children_(std::move(children)) {}
|
||||
|
||||
std::string DebugStringConvertibleItem::getDebugName() const {
|
||||
return name_;
|
||||
|
|
|
@ -24,10 +24,10 @@ class DebugStringConvertibleItem : public DebugStringConvertible {
|
|||
DebugStringConvertibleItem(const DebugStringConvertibleItem &item) = default;
|
||||
|
||||
DebugStringConvertibleItem(
|
||||
const std::string &name = "",
|
||||
const std::string &value = "",
|
||||
const SharedDebugStringConvertibleList &props = {},
|
||||
const SharedDebugStringConvertibleList &children = {});
|
||||
std::string name = "",
|
||||
std::string value = "",
|
||||
SharedDebugStringConvertibleList props = {},
|
||||
SharedDebugStringConvertibleList children = {});
|
||||
|
||||
std::string getDebugName() const override;
|
||||
std::string getDebugValue() const override;
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
|
||||
#include "ComponentBuilder.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
ComponentBuilder::ComponentBuilder(
|
||||
ComponentDescriptorRegistry::Shared const &componentDescriptorRegistry)
|
||||
: componentDescriptorRegistry_(componentDescriptorRegistry){};
|
||||
ComponentDescriptorRegistry::Shared componentDescriptorRegistry)
|
||||
: componentDescriptorRegistry_(std::move(componentDescriptorRegistry)){};
|
||||
|
||||
ShadowNode::Unshared ComponentBuilder::build(
|
||||
ElementFragment const &elementFragment) const {
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace react {
|
|||
class ComponentBuilder final {
|
||||
public:
|
||||
ComponentBuilder(
|
||||
ComponentDescriptorRegistry::Shared const &componentDescriptorRegistry);
|
||||
ComponentDescriptorRegistry::Shared componentDescriptorRegistry);
|
||||
|
||||
/*
|
||||
* Copyable and movable.
|
||||
|
|
|
@ -29,7 +29,7 @@ class ImageRequest final {
|
|||
* The default constructor
|
||||
*/
|
||||
ImageRequest(
|
||||
const ImageSource &imageSource,
|
||||
ImageSource imageSource,
|
||||
std::shared_ptr<const ImageTelemetry> telemetry);
|
||||
|
||||
/*
|
||||
|
|
|
@ -7,13 +7,15 @@
|
|||
|
||||
#include "ImageResponse.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
ImageResponse::ImageResponse(
|
||||
const std::shared_ptr<void> &image,
|
||||
const std::shared_ptr<void> &metadata)
|
||||
: image_(image), metadata_(metadata) {}
|
||||
std::shared_ptr<void> image,
|
||||
std::shared_ptr<void> metadata)
|
||||
: image_(std::move(image)), metadata_(std::move(metadata)) {}
|
||||
|
||||
std::shared_ptr<void> ImageResponse::getImage() const {
|
||||
return image_;
|
||||
|
|
|
@ -23,9 +23,7 @@ class ImageResponse final {
|
|||
Failed,
|
||||
};
|
||||
|
||||
ImageResponse(
|
||||
const std::shared_ptr<void> &image,
|
||||
const std::shared_ptr<void> &metadata);
|
||||
ImageResponse(std::shared_ptr<void> image, std::shared_ptr<void> metadata);
|
||||
|
||||
std::shared_ptr<void> getImage() const;
|
||||
|
||||
|
|
|
@ -7,13 +7,15 @@
|
|||
|
||||
#include "ImageRequest.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
ImageRequest::ImageRequest(
|
||||
const ImageSource &imageSource,
|
||||
ImageSource imageSource,
|
||||
std::shared_ptr<const ImageTelemetry> telemetry)
|
||||
: imageSource_(imageSource), telemetry_(telemetry) {
|
||||
: imageSource_(std::move(imageSource)), telemetry_(std::move(telemetry)) {
|
||||
// Not implemented.
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ namespace facebook {
|
|||
namespace react {
|
||||
|
||||
ImageRequest::ImageRequest(
|
||||
ImageSource const &imageSource,
|
||||
ImageSource imageSource,
|
||||
std::shared_ptr<const ImageTelemetry> telemetry)
|
||||
: imageSource_(imageSource), telemetry_(telemetry) {
|
||||
: imageSource_(std::move(imageSource)), telemetry_(std::move(telemetry)) {
|
||||
coordinator_ = std::make_shared<ImageResponseObserverCoordinator>();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,13 @@
|
|||
#include <glog/logging.h>
|
||||
#include <jsi/instrumentation.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
LeakChecker::LeakChecker(RuntimeExecutor const &runtimeExecutor)
|
||||
: runtimeExecutor_(runtimeExecutor) {}
|
||||
LeakChecker::LeakChecker(RuntimeExecutor runtimeExecutor)
|
||||
: runtimeExecutor_(std::move(runtimeExecutor)) {}
|
||||
|
||||
void LeakChecker::uiManagerDidCreateShadowNodeFamily(
|
||||
ShadowNodeFamily::Shared const &shadowNodeFamily) const {
|
||||
|
|
|
@ -20,7 +20,7 @@ using GarbageCollectionTrigger = std::function<void()>;
|
|||
|
||||
class LeakChecker final {
|
||||
public:
|
||||
LeakChecker(RuntimeExecutor const &runtimeExecutor);
|
||||
LeakChecker(RuntimeExecutor runtimeExecutor);
|
||||
|
||||
void uiManagerDidCreateShadowNodeFamily(
|
||||
ShadowNodeFamily::Shared const &shadowNodeFamily) const;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "ShadowViewMutation.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -91,9 +93,9 @@ ShadowViewMutation::ShadowViewMutation(
|
|||
ShadowView newChildShadowView,
|
||||
int index)
|
||||
: type(type),
|
||||
parentShadowView(parentShadowView),
|
||||
oldChildShadowView(oldChildShadowView),
|
||||
newChildShadowView(newChildShadowView),
|
||||
parentShadowView(std::move(parentShadowView)),
|
||||
oldChildShadowView(std::move(oldChildShadowView)),
|
||||
newChildShadowView(std::move(newChildShadowView)),
|
||||
index(index) {}
|
||||
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
|
||||
#include "RuntimeScheduler.h"
|
||||
|
||||
#include <utility>
|
||||
#include "ErrorUtils.h"
|
||||
|
||||
namespace facebook {
|
||||
|
@ -14,9 +16,9 @@ namespace react {
|
|||
#pragma mark - Public
|
||||
|
||||
RuntimeScheduler::RuntimeScheduler(
|
||||
RuntimeExecutor const &runtimeExecutor,
|
||||
RuntimeExecutor runtimeExecutor,
|
||||
std::function<RuntimeSchedulerTimePoint()> now)
|
||||
: runtimeExecutor_(runtimeExecutor), now_(now) {}
|
||||
: runtimeExecutor_(std::move(runtimeExecutor)), now_(std::move(now)) {}
|
||||
|
||||
void RuntimeScheduler::scheduleWork(
|
||||
std::function<void(jsi::Runtime &)> callback) const {
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace react {
|
|||
class RuntimeScheduler final {
|
||||
public:
|
||||
RuntimeScheduler(
|
||||
RuntimeExecutor const &runtimeExecutor,
|
||||
RuntimeExecutor runtimeExecutor,
|
||||
std::function<RuntimeSchedulerTimePoint()> now =
|
||||
RuntimeSchedulerClock::now);
|
||||
/*
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <react/debug/react_native_assert.h>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
@ -57,8 +58,8 @@ std::shared_ptr<RuntimeSchedulerBinding> RuntimeSchedulerBinding::getBinding(
|
|||
}
|
||||
|
||||
RuntimeSchedulerBinding::RuntimeSchedulerBinding(
|
||||
std::shared_ptr<RuntimeScheduler> const &runtimeScheduler)
|
||||
: runtimeScheduler_(runtimeScheduler) {}
|
||||
std::shared_ptr<RuntimeScheduler> runtimeScheduler)
|
||||
: runtimeScheduler_(std::move(runtimeScheduler)) {}
|
||||
|
||||
bool RuntimeSchedulerBinding::getIsSynchronous() const {
|
||||
return runtimeScheduler_->getIsSynchronous();
|
||||
|
|
|
@ -18,8 +18,7 @@ namespace react {
|
|||
*/
|
||||
class RuntimeSchedulerBinding : public jsi::HostObject {
|
||||
public:
|
||||
RuntimeSchedulerBinding(
|
||||
std::shared_ptr<RuntimeScheduler> const &runtimeScheduler);
|
||||
RuntimeSchedulerBinding(std::shared_ptr<RuntimeScheduler> runtimeScheduler);
|
||||
|
||||
/*
|
||||
* Installs RuntimeSchedulerBinding into JavaScript runtime if needed.
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
|
||||
#include "RuntimeSchedulerCallInvoker.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
RuntimeSchedulerCallInvoker::RuntimeSchedulerCallInvoker(
|
||||
std::weak_ptr<RuntimeScheduler> runtimeScheduler)
|
||||
: runtimeScheduler_(runtimeScheduler) {}
|
||||
: runtimeScheduler_(std::move(runtimeScheduler)) {}
|
||||
|
||||
void RuntimeSchedulerCallInvoker::invokeAsync(std::function<void()> &&func) {
|
||||
if (auto runtimeScheduler = runtimeScheduler_.lock()) {
|
||||
|
|
|
@ -9,17 +9,19 @@
|
|||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
SynchronousEventBeat::SynchronousEventBeat(
|
||||
RunLoopObserver::Unique uiRunLoopObserver,
|
||||
RuntimeExecutor runtimeExecutor,
|
||||
std::shared_ptr<RuntimeScheduler> const &runtimeScheduler)
|
||||
std::shared_ptr<RuntimeScheduler> runtimeScheduler)
|
||||
: EventBeat({}),
|
||||
uiRunLoopObserver_(std::move(uiRunLoopObserver)),
|
||||
runtimeExecutor_(std::move(runtimeExecutor)),
|
||||
runtimeScheduler_(runtimeScheduler) {
|
||||
runtimeScheduler_(std::move(runtimeScheduler)) {
|
||||
uiRunLoopObserver_->setDelegate(this);
|
||||
uiRunLoopObserver_->enable();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class SynchronousEventBeat final : public EventBeat,
|
|||
SynchronousEventBeat(
|
||||
RunLoopObserver::Unique uiRunLoopObserver,
|
||||
RuntimeExecutor runtimeExecutor,
|
||||
std::shared_ptr<RuntimeScheduler> const &runtimeScheduler);
|
||||
std::shared_ptr<RuntimeScheduler> runtimeScheduler);
|
||||
|
||||
void induce() const override;
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -19,7 +21,7 @@ TransactionTelemetry::TransactionTelemetry()
|
|||
|
||||
TransactionTelemetry::TransactionTelemetry(
|
||||
std::function<TelemetryTimePoint()> now)
|
||||
: now_{now} {}
|
||||
: now_{std::move(now)} {}
|
||||
|
||||
TransactionTelemetry *TransactionTelemetry::threadLocalTelemetry() {
|
||||
return threadLocalTransactionTelemetry;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "TextMeasureCache.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -30,7 +32,7 @@ LineMeasurement::LineMeasurement(
|
|||
Float capHeight,
|
||||
Float ascender,
|
||||
Float xHeight)
|
||||
: text(text),
|
||||
: text(std::move(text)),
|
||||
frame(frame),
|
||||
descender(descender),
|
||||
capHeight(capHeight),
|
||||
|
|
|
@ -9,13 +9,15 @@
|
|||
|
||||
#include <react/utils/Telemetry.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
TimelineSnapshot::TimelineSnapshot(
|
||||
RootShadowNode::Shared const &rootShadowNode,
|
||||
RootShadowNode::Shared rootShadowNode,
|
||||
int index) noexcept
|
||||
: rootShadowNode_(rootShadowNode),
|
||||
: rootShadowNode_(std::move(rootShadowNode)),
|
||||
frame_(TimelineFrame{index, telemetryTimePointNow()}) {}
|
||||
|
||||
RootShadowNode::Shared TimelineSnapshot::getRootShadowNode() const noexcept {
|
||||
|
|
|
@ -20,9 +20,7 @@ class TimelineSnapshot final {
|
|||
public:
|
||||
using List = std::vector<TimelineSnapshot>;
|
||||
|
||||
TimelineSnapshot(
|
||||
RootShadowNode::Shared const &rootShadowNode,
|
||||
int index) noexcept;
|
||||
TimelineSnapshot(RootShadowNode::Shared rootShadowNode, int index) noexcept;
|
||||
|
||||
TimelineFrame getFrame() const noexcept;
|
||||
RootShadowNode::Shared getRootShadowNode() const noexcept;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
static std::unique_ptr<LeakChecker> constructLeakCheckerIfNeeded(
|
||||
|
@ -31,10 +33,10 @@ static std::unique_ptr<LeakChecker> constructLeakCheckerIfNeeded(
|
|||
|
||||
UIManager::UIManager(
|
||||
RuntimeExecutor const &runtimeExecutor,
|
||||
BackgroundExecutor const &backgroundExecutor,
|
||||
BackgroundExecutor backgroundExecutor,
|
||||
ContextContainer::Shared contextContainer)
|
||||
: runtimeExecutor_(runtimeExecutor),
|
||||
backgroundExecutor_(backgroundExecutor),
|
||||
backgroundExecutor_(std::move(backgroundExecutor)),
|
||||
contextContainer_(std::move(contextContainer)),
|
||||
leakChecker_(constructLeakCheckerIfNeeded(runtimeExecutor)) {}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class UIManager final : public ShadowTreeDelegate {
|
|||
public:
|
||||
UIManager(
|
||||
RuntimeExecutor const &runtimeExecutor,
|
||||
BackgroundExecutor const &backgroundExecutor,
|
||||
BackgroundExecutor backgroundExecutor,
|
||||
ContextContainer::Shared contextContainer);
|
||||
|
||||
~UIManager();
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <react/renderer/runtimescheduler/RuntimeSchedulerBinding.h>
|
||||
#include <react/renderer/uimanager/primitives.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "bindingUtils.h"
|
||||
|
||||
namespace facebook::react {
|
||||
|
@ -53,9 +55,10 @@ std::shared_ptr<UIManagerBinding> UIManagerBinding::getBinding(
|
|||
}
|
||||
|
||||
UIManagerBinding::UIManagerBinding(
|
||||
std::shared_ptr<UIManager> const &uiManager,
|
||||
RuntimeExecutor const &runtimeExecutor)
|
||||
: uiManager_(uiManager), runtimeExecutor_(runtimeExecutor) {}
|
||||
std::shared_ptr<UIManager> uiManager,
|
||||
RuntimeExecutor runtimeExecutor)
|
||||
: uiManager_(std::move(uiManager)),
|
||||
runtimeExecutor_(std::move(runtimeExecutor)) {}
|
||||
|
||||
UIManagerBinding::~UIManagerBinding() {
|
||||
LOG(WARNING) << "UIManagerBinding::~UIManagerBinding() was called (address: "
|
||||
|
|
|
@ -38,8 +38,8 @@ class UIManagerBinding : public jsi::HostObject {
|
|||
static std::shared_ptr<UIManagerBinding> getBinding(jsi::Runtime &runtime);
|
||||
|
||||
UIManagerBinding(
|
||||
std::shared_ptr<UIManager> const &uiManager,
|
||||
RuntimeExecutor const &runtimeExecutor);
|
||||
std::shared_ptr<UIManager> uiManager,
|
||||
RuntimeExecutor runtimeExecutor);
|
||||
|
||||
~UIManagerBinding();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче