Fabric: Equality operators for ShadowNode
Summary: Test for equality will be used in ShadowNode Tree Diffing algorithm. Reviewed By: fkgozali Differential Revision: D7467802 fbshipit-source-id: 5383add9fc7d7e4a772ca16e70a54f7e0c36823a
This commit is contained in:
parent
4ebb57b0ba
commit
1f969d3440
|
@ -116,6 +116,21 @@ void ShadowNode::clearSourceNode() {
|
|||
sourceNode_.reset();
|
||||
}
|
||||
|
||||
#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_;
|
||||
}
|
||||
|
||||
bool ShadowNode::operator!=(const ShadowNode& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
#pragma mark - DebugStringConvertible
|
||||
|
||||
std::string ShadowNode::getDebugName() const {
|
||||
|
|
|
@ -67,6 +67,18 @@ public:
|
|||
void replaceChild(const SharedShadowNode &oldChild, const SharedShadowNode &newChild);
|
||||
void clearSourceNode();
|
||||
|
||||
#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 mutation instructions
|
||||
* 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
|
||||
|
||||
std::string getDebugName() const override;
|
||||
|
|
Loading…
Reference in New Issue