Fabric: ShadowNode::getCommitedState() now returns by value

Summary: Returning a shared pointer by const reference in this context is not correct/safe because the object (the ShadowNode) doesn't own the object, so the caller cannot reason about the lifetime (esp. in a multithreaded environment).

Reviewed By: mdvacca

Differential Revision: D15958737

fbshipit-source-id: 8f03e6530d07d63ece5f955055c5c67c204b8223
This commit is contained in:
Valentin Shergin
2019-06-22 18:50:33 -07:00
committed by Facebook Github Bot
parent 3915c0fa61
commit bd19f3bd13
4 changed files with 4 additions and 4 deletions
@@ -120,7 +120,7 @@ const State::Shared &ShadowNode::getState() const {
return state_;
}
const State::Shared &ShadowNode::getCommitedState() const {
State::Shared ShadowNode::getCommitedState() const {
return state_ ? state_->getCommitedState()
: ShadowNodeFragment::statePlaceholder();
}
@@ -115,7 +115,7 @@ class ShadowNode : public virtual Sealable,
* Returns a momentary value of currently committed state associated with a
* family of nodes which this node belongs to.
*/
const State::Shared &getCommitedState() const;
State::Shared getCommitedState() const;
/*
* Returns a local data associated with the node.
+1 -1
View File
@@ -29,7 +29,7 @@ void State::commit(const ShadowNode &shadowNode) const {
stateCoordinator_->setTarget(StateTarget{shadowNode});
}
const State::Shared &State::getCommitedState() const {
State::Shared State::getCommitedState() const {
return stateCoordinator_->getTarget().getShadowNode().getState();
}
+1 -1
View File
@@ -48,7 +48,7 @@ class State {
/*
* Must be used by `ShadowNode` *only*.
*/
const State::Shared &getCommitedState() const;
State::Shared getCommitedState() const;
};
} // namespace react