Remove Props copy constructor and assignment operators (#40936)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40936

Found a couple of places where we were accidentally copying Props structs. These can be big, so we should avoid doing so.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D50263678

fbshipit-source-id: f60a0370df9b7f3f146988148d5192d3cc32fb4e
This commit is contained in:
Pieter De Baets 2023-10-16 05:56:33 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 171a479150
Коммит bbc517c8c8
4 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -368,7 +368,7 @@ void YogaLayoutableShadowNode::updateYogaChildren() {
void YogaLayoutableShadowNode::updateYogaProps() {
ensureUnsealed();
auto props = static_cast<const YogaStylableProps&>(*props_);
auto& props = static_cast<const YogaStylableProps&>(*props_);
auto styleResult = applyAliasedProps(props.yogaStyle, props);
// Resetting `dirty` flag only if `yogaStyle` portion of `Props` was changed.

Просмотреть файл

@ -76,7 +76,8 @@ class ConcreteShadowNode : public BaseShadowNodeT {
const Props::Shared& baseProps = nullptr) {
return std::make_shared<PropsT>(
context,
baseProps ? static_cast<const PropsT&>(*baseProps) : PropsT(),
baseProps ? static_cast<const PropsT&>(*baseProps)
: *defaultSharedProps(),
rawProps);
}

Просмотреть файл

@ -36,6 +36,9 @@ class Props : public virtual Sealable, public virtual DebugStringConvertible {
const RawProps& rawProps);
virtual ~Props() = default;
Props(const Props& other) = delete;
Props& operator=(const Props& other) = delete;
/**
* Set a prop value via iteration (see enableIterator above).
* If setProp is defined for a particular props struct, it /must/

Просмотреть файл

@ -33,9 +33,7 @@ static bool isViewListeningToEvents(
const ShadowNode& shadowNode,
std::initializer_list<ViewEvents::Offset> eventTypes) {
if (shadowNode.getTraits().check(ShadowNodeTraits::Trait::ViewKind)) {
auto props = shadowNode.getProps();
auto viewProps = static_cast<const ViewProps&>(*props);
auto& viewProps = static_cast<const ViewProps&>(*shadowNode.getProps());
for (const ViewEvents::Offset eventType : eventTypes) {
if (viewProps.events[eventType]) {
return true;