Fabric: Removing `ShadowNode::operator==`

Summary:
@public
We don't need this anymore.
The same functionality is now implemented as `ShadowView::operator==` in much more reasonable way.

Reviewed By: sahrens

Differential Revision: D9649821

fbshipit-source-id: 8cd5f3cb4f583fd10d2d1e060aba914541341b5b
This commit is contained in:
Valentin Shergin 2018-09-07 21:44:18 -07:00 committed by Facebook Github Bot
parent dd627479c2
commit 1183d82884
5 changed files with 9 additions and 46 deletions

View File

@ -113,17 +113,6 @@ public:
return clonedChildShadowNode.get(); return clonedChildShadowNode.get();
} }
#pragma mark - Equality
bool operator==(const ShadowNode& rhs) const override {
if (!ShadowNode::operator==(rhs)) {
return false;
}
const auto &other = static_cast<const ConcreteViewShadowNode&>(rhs);
return getLayoutMetrics() == other.getLayoutMetrics();
}
#pragma mark - DebugStringConvertible #pragma mark - DebugStringConvertible
SharedDebugStringConvertibleList getDebugProps() const override { SharedDebugStringConvertibleList getDebugProps() const override {

View File

@ -143,23 +143,6 @@ void ShadowNode::cloneChildrenIfShared() {
children_ = std::make_shared<SharedShadowNodeList>(*children_); children_ = std::make_shared<SharedShadowNodeList>(*children_);
} }
#pragma mark - Equality
bool ShadowNode::operator==(const ShadowNode& rhs) const {
// Note: Child nodes are not considered as part of instance's value
// and/or identity.
return
tag_ == rhs.tag_ &&
rootTag_ == rhs.rootTag_ &&
props_ == rhs.props_ &&
eventEmitter_ == rhs.eventEmitter_ &&
localData_ == rhs.localData_;
}
bool ShadowNode::operator!=(const ShadowNode& rhs) const {
return !(*this == rhs);
}
#pragma mark - DebugStringConvertible #pragma mark - DebugStringConvertible
std::string ShadowNode::getDebugName() const { std::string ShadowNode::getDebugName() const {

View File

@ -101,18 +101,6 @@ public:
*/ */
void setLocalData(const SharedLocalData &localData); void setLocalData(const SharedLocalData &localData);
#pragma mark - Equality
/*
* Equality operators.
* Use this to compare `ShadowNode`s values for equality (and non-equality).
* Same values indicates that nodes must not produce mutations
* during tree diffing process.
* Child nodes are not considered as part of the value.
*/
virtual bool operator==(const ShadowNode& rhs) const;
virtual bool operator!=(const ShadowNode& rhs) const;
#pragma mark - DebugStringConvertible #pragma mark - DebugStringConvertible
std::string getDebugName() const override; std::string getDebugName() const override;

View File

@ -158,10 +158,10 @@ TEST(ShadowNodeTest, handleLocalData) {
thirdNode->setLocalData(localDataOver9000); thirdNode->setLocalData(localDataOver9000);
// LocalData object are compared by pointer, not by value. // LocalData object are compared by pointer, not by value.
ASSERT_EQ(*firstNode, *secondNode); ASSERT_EQ(firstNode->getLocalData(), secondNode->getLocalData());
ASSERT_NE(*firstNode, *thirdNode); ASSERT_NE(firstNode->getLocalData(), thirdNode->getLocalData());
secondNode->setLocalData(anotherLocalData42); secondNode->setLocalData(anotherLocalData42);
ASSERT_NE(*firstNode, *secondNode); ASSERT_NE(firstNode->getLocalData(), secondNode->getLocalData());
// LocalData cannot be changed for sealed shadow node. // LocalData cannot be changed for sealed shadow node.
secondNode->sealRecursive(); secondNode->sealRecursive();

View File

@ -211,12 +211,15 @@ ShadowViewMutationList calculateShadowViewMutations(
ShadowViewMutationList mutations; ShadowViewMutationList mutations;
if (oldRootShadowNode != newRootShadowNode) { auto oldRootShadowView = ShadowView(oldRootShadowNode);
auto newRootShadowView = ShadowView(newRootShadowNode);
if (oldRootShadowView != newRootShadowView) {
mutations.push_back( mutations.push_back(
ShadowViewMutation::UpdateMutation( ShadowViewMutation::UpdateMutation(
ShadowView(), ShadowView(),
ShadowView(oldRootShadowNode), oldRootShadowView,
ShadowView(newRootShadowNode), newRootShadowView,
-1 -1
) )
); );