mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 19:15:05 +00:00
Fabric: ShadowNodeCloneFunction
signature was unified with ShadowNode copy constructor
Summary: @public Now it accepts `const ShadowNode &` instead of `std::shared_ptr<const ShadowNode>` which is more reasonable (and more performant) becasue the function must not retain ownershipt. Reviewed By: mdvacca Differential Revision: D9073921 fbshipit-source-id: c24c475615e0f81b3e004e118dea7565d8e757b4
This commit is contained in:
parent
6230147e73
commit
1d93d70af4
@ -113,9 +113,8 @@ private:
|
|||||||
|
|
||||||
ShadowNodeCloneFunction getCloneFunction() const {
|
ShadowNodeCloneFunction getCloneFunction() const {
|
||||||
if (!cloneFunction_) {
|
if (!cloneFunction_) {
|
||||||
cloneFunction_ = [this](const SharedShadowNode &shadowNode, const ShadowNodeFragment &fragment) {
|
cloneFunction_ = [this](const ShadowNode &shadowNode, const ShadowNodeFragment &fragment) {
|
||||||
assert(std::dynamic_pointer_cast<const ShadowNodeT>(shadowNode));
|
return this->cloneShadowNode(shadowNode, fragment);
|
||||||
return this->cloneShadowNode(*shadowNode, fragment);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ ShadowNode::ShadowNode(
|
|||||||
|
|
||||||
UnsharedShadowNode ShadowNode::clone(const ShadowNodeFragment &fragment) const {
|
UnsharedShadowNode ShadowNode::clone(const ShadowNodeFragment &fragment) const {
|
||||||
assert(cloneFunction_);
|
assert(cloneFunction_);
|
||||||
return cloneFunction_(shared_from_this(), fragment);
|
return cloneFunction_(*this, fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Getters
|
#pragma mark - Getters
|
||||||
|
@ -32,7 +32,7 @@ using SharedShadowNodeSharedList = std::shared_ptr<const SharedShadowNodeList>;
|
|||||||
using SharedShadowNodeUnsharedList = std::shared_ptr<SharedShadowNodeList>;
|
using SharedShadowNodeUnsharedList = std::shared_ptr<SharedShadowNodeList>;
|
||||||
|
|
||||||
using ShadowNodeCloneFunction = std::function<UnsharedShadowNode(
|
using ShadowNodeCloneFunction = std::function<UnsharedShadowNode(
|
||||||
const SharedShadowNode &sourceShadowNode,
|
const ShadowNode &sourceShadowNode,
|
||||||
const ShadowNodeFragment &fragment
|
const ShadowNodeFragment &fragment
|
||||||
)>;
|
)>;
|
||||||
|
|
||||||
|
@ -117,9 +117,9 @@ TEST(ShadowNodeTest, handleCloneFunction) {
|
|||||||
.props = std::make_shared<const TestProps>(),
|
.props = std::make_shared<const TestProps>(),
|
||||||
.children = ShadowNode::emptySharedShadowNodeSharedList()
|
.children = ShadowNode::emptySharedShadowNodeSharedList()
|
||||||
},
|
},
|
||||||
[](const SharedShadowNode &shadowNode, const ShadowNodeFragment &fragment) {
|
[](const ShadowNode &shadowNode, const ShadowNodeFragment &fragment) {
|
||||||
return std::make_shared<TestShadowNode>(
|
return std::make_shared<TestShadowNode>(
|
||||||
*std::static_pointer_cast<const TestShadowNode>(shadowNode),
|
shadowNode,
|
||||||
fragment
|
fragment
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user