From 56501dcc4771a329a25cdaf83c32683e348a7dfe Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 4 Mar 2019 09:57:01 -0800 Subject: [PATCH] Fabric: Changing the shape of ShadowViewNodePair class Summary: I am not sure why it compiled before, it clearly should not, IMO. The `const` types (and references!) are not allowed inside `std::vector` because they are not assignable. Some experiments that I did caused compilation errors here, so I am changing that to be actually correct. Reviewed By: JoshuaGross Differential Revision: D14249199 fbshipit-source-id: 07a22ef13f5de9dfc7ab307493419e6006994bc2 --- ReactCommon/fabric/mounting/Differentiator.cpp | 14 +++++++------- ReactCommon/fabric/mounting/ShadowView.cpp | 2 +- ReactCommon/fabric/mounting/ShadowView.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ReactCommon/fabric/mounting/Differentiator.cpp b/ReactCommon/fabric/mounting/Differentiator.cpp index 2f8a932c6bf..62bf19d1229 100644 --- a/ReactCommon/fabric/mounting/Differentiator.cpp +++ b/ReactCommon/fabric/mounting/Differentiator.cpp @@ -39,7 +39,7 @@ static void sliceChildShadowNodeViewPairsRecursively( *childShadowNode); } else { shadowView.layoutMetrics.frame.origin += layoutOffset; - pairList.push_back({shadowView, *childShadowNode}); + pairList.push_back({shadowView, childShadowNode.get()}); } } } @@ -98,9 +98,9 @@ static void calculateShadowViewMutations( } const auto oldGrandChildPairs = - sliceChildShadowNodeViewPairs(oldChildPair.shadowNode); + sliceChildShadowNodeViewPairs(*oldChildPair.shadowNode); const auto newGrandChildPairs = - sliceChildShadowNodeViewPairs(newChildPair.shadowNode); + sliceChildShadowNodeViewPairs(*newChildPair.shadowNode); calculateShadowViewMutations( *(newGrandChildPairs.size() ? &downwardMutations : &destructiveDownwardMutations), @@ -145,7 +145,7 @@ static void calculateShadowViewMutations( calculateShadowViewMutations( destructiveDownwardMutations, oldChildPair.shadowView, - sliceChildShadowNodeViewPairs(oldChildPair.shadowNode), + sliceChildShadowNodeViewPairs(*oldChildPair.shadowNode), {}); } else { // The old view *was* (re)inserted. @@ -154,9 +154,9 @@ static void calculateShadowViewMutations( const auto &newChildPair = it->second; if (newChildPair.shadowView != oldChildPair.shadowView) { const auto oldGrandChildPairs = - sliceChildShadowNodeViewPairs(oldChildPair.shadowNode); + sliceChildShadowNodeViewPairs(*oldChildPair.shadowNode); const auto newGrandChildPairs = - sliceChildShadowNodeViewPairs(newChildPair.shadowNode); + sliceChildShadowNodeViewPairs(*newChildPair.shadowNode); calculateShadowViewMutations( *(newGrandChildPairs.size() ? &downwardMutations : &destructiveDownwardMutations), @@ -191,7 +191,7 @@ static void calculateShadowViewMutations( downwardMutations, newChildPair.shadowView, {}, - sliceChildShadowNodeViewPairs(newChildPair.shadowNode)); + sliceChildShadowNodeViewPairs(*newChildPair.shadowNode)); } // All mutations in an optimal order: diff --git a/ReactCommon/fabric/mounting/ShadowView.cpp b/ReactCommon/fabric/mounting/ShadowView.cpp index 53f87e81665..0cd8eee8310 100644 --- a/ReactCommon/fabric/mounting/ShadowView.cpp +++ b/ReactCommon/fabric/mounting/ShadowView.cpp @@ -51,7 +51,7 @@ bool ShadowView::operator!=(const ShadowView &rhs) const { } bool ShadowViewNodePair::operator==(const ShadowViewNodePair &rhs) const { - return &this->shadowNode == &rhs.shadowNode; + return this->shadowNode == rhs.shadowNode; } bool ShadowViewNodePair::operator!=(const ShadowViewNodePair &rhs) const { diff --git a/ReactCommon/fabric/mounting/ShadowView.h b/ReactCommon/fabric/mounting/ShadowView.h index bfa972cda8b..f343c5aac1f 100644 --- a/ReactCommon/fabric/mounting/ShadowView.h +++ b/ReactCommon/fabric/mounting/ShadowView.h @@ -49,8 +49,8 @@ struct ShadowView final { * Describes pair of a `ShadowView` and a `ShadowNode`. */ struct ShadowViewNodePair final { - const ShadowView shadowView; - const ShadowNode &shadowNode; + ShadowView shadowView; + ShadowNode const *shadowNode; /* * The stored pointer to `ShadowNode` represents an indentity of the pair.