Skip to content

Commit

Permalink
Delete RawProps assignment operators (#49030)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #49030

Overwriting another RawProps object via `operator=` is rarely what we want, and these objects should be considered immutable once constructed.

This will catch issues such as D68633985

Changelog: [General][Changed] Removed `RawProps::operator=`

Reviewed By: sammy-SC

Differential Revision: D68797484

fbshipit-source-id: 766a65db1dbf4485c78007f8f69cc9426d27a943
  • Loading branch information
javache authored and facebook-github-bot committed Jan 29, 2025
1 parent 5d7feda commit e4d1cf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
16 changes: 0 additions & 16 deletions packages/react-native/ReactCommon/react/renderer/core/RawProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ inline bool isYogaStyleProp(const std::string& prop) {
}
} // namespace

RawProps::RawProps() {
mode_ = Mode::Empty;
}

/*
* Creates an object with given `runtime` and `value`.
*/
Expand Down Expand Up @@ -149,18 +145,6 @@ RawProps::RawProps(const RawProps& other) noexcept {
ignoreYogaStyleProps_ = other.ignoreYogaStyleProps_;
}

RawProps& RawProps::operator=(const RawProps& other) noexcept {
mode_ = other.mode_;
if (mode_ == Mode::JSI) {
runtime_ = other.runtime_;
value_ = jsi::Value(*runtime_, other.value_);
} else if (mode_ == Mode::Dynamic) {
dynamic_ = other.dynamic_;
}
ignoreYogaStyleProps_ = other.ignoreYogaStyleProps_;
return *this;
}

void RawProps::parse(const RawPropsParser& parser) noexcept {
react_native_assert(parser_ == nullptr && "A parser was already assigned.");
parser_ = &parser;
Expand Down
11 changes: 6 additions & 5 deletions packages/react-native/ReactCommon/react/renderer/core/RawProps.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ class RawProps final {
/*
* Creates empty RawProps objects.
*/
RawProps();
RawProps() : mode_(Mode::Empty) {}

/*
* Creates an object with given `runtime` and `value`.
*/
RawProps(jsi::Runtime& runtime, const jsi::Value& value) noexcept;

explicit RawProps(const RawProps& rawProps) noexcept;
RawProps& operator=(const RawProps& other) noexcept;

RawProps(RawProps&& other) noexcept = default;
RawProps& operator=(RawProps&& other) noexcept = default;

RawProps& operator=(const RawProps& other) noexcept = delete;
RawProps& operator=(RawProps&& other) noexcept = delete;

/*
* Creates an object with given `folly::dynamic` object.
Expand Down Expand Up @@ -112,8 +112,9 @@ class RawProps final {
/*
* Source artefacts:
*/

// Mode
mutable Mode mode_;
Mode mode_;

// Case 1: Source data is represented as `jsi::Object`.
jsi::Runtime* runtime_{};
Expand Down

0 comments on commit e4d1cf8

Please sign in to comment.