Skip to content

Commit b985263

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
small changes to ctor of State and ConcreteState
Summary: changelog: [internal] 1. `ConcreteState` and `State` were taking shared_ptr to family even though they only use weak_ptr. 2. `ConcreteState` was taking a const& to `data`. It unconditionally takes ownership of data, make it obvious in the interface. Reviewed By: lenaic Differential Revision: D74024980
1 parent 3ac16dd commit b985263

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

packages/react-native/ReactCommon/react/renderer/core/ConcreteState.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,15 @@ class ConcreteState : public State {
4949
/*
5050
* Creates an updated `State` object with given previous one and `data`.
5151
*/
52-
explicit ConcreteState(const SharedData& data, const State& previousState)
53-
: State(data, previousState) {}
52+
explicit ConcreteState(SharedData data, const State& previousState)
53+
: State(std::move(data), previousState) {}
5454

5555
/*
5656
* Creates a first-of-its-family `State` object with given `family` and
5757
* `data`.
5858
*/
59-
explicit ConcreteState(
60-
const SharedData& data,
61-
const ShadowNodeFamily::Shared& family)
62-
: State(data, family) {}
59+
explicit ConcreteState(SharedData data, ShadowNodeFamily::Weak family)
60+
: State(std::move(data), std::move(family)) {}
6361

6462
~ConcreteState() override = default;
6563

packages/react-native/ReactCommon/react/renderer/core/State.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ State::State(StateData::Shared data, const State& previousState)
2121
data_(std::move(data)),
2222
revision_(previousState.revision_ + 1){};
2323

24-
State::State(StateData::Shared data, const ShadowNodeFamily::Shared& family)
25-
: family_(family),
24+
State::State(StateData::Shared data, ShadowNodeFamily::Weak family)
25+
: family_(std::move(family)),
2626
data_(std::move(data)),
2727
revision_{State::initialRevisionValue} {};
2828

packages/react-native/ReactCommon/react/renderer/core/State.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ class State {
3434
* type-erasured arguments impossible.
3535
*/
3636
explicit State(StateData::Shared data, const State& previousState);
37-
explicit State(
38-
StateData::Shared data,
39-
const ShadowNodeFamily::Shared& family);
37+
explicit State(StateData::Shared data, ShadowNodeFamily::Weak family);
4038

4139
public:
4240
virtual ~State() = default;

0 commit comments

Comments
 (0)