mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Farbic: Making ShadowNode::revision_ debug only
Summary: We use this piece of data only for debug purposes, so there is no need to pay for that in prod. Changelog: [Internal] - Small optimization in `ShadowNode` (Fabric) Reviewed By: JoshuaGross Differential Revision: D17961209 fbshipit-source-id: 2a0d609ac4d3c4815b26789551a4c51bcf91dea4
This commit is contained in:
committed by
Facebook Github Bot
parent
a4ebd87a81
commit
05862faab4
@@ -34,7 +34,11 @@ bool ShadowNode::sameFamily(const ShadowNode &first, const ShadowNode &second) {
|
||||
ShadowNode::ShadowNode(
|
||||
const ShadowNodeFragment &fragment,
|
||||
const ComponentDescriptor &componentDescriptor)
|
||||
: props_(fragment.props),
|
||||
:
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
revision_(1),
|
||||
#endif
|
||||
props_(fragment.props),
|
||||
children_(
|
||||
fragment.children ? fragment.children
|
||||
: emptySharedShadowNodeSharedList()),
|
||||
@@ -44,8 +48,7 @@ ShadowNode::ShadowNode(
|
||||
fragment.surfaceId,
|
||||
fragment.eventEmitter,
|
||||
componentDescriptor)),
|
||||
childrenAreShared_(true),
|
||||
revision_(1) {
|
||||
childrenAreShared_(true) {
|
||||
assert(props_);
|
||||
assert(children_);
|
||||
|
||||
@@ -57,7 +60,11 @@ ShadowNode::ShadowNode(
|
||||
ShadowNode::ShadowNode(
|
||||
const ShadowNode &sourceShadowNode,
|
||||
const ShadowNodeFragment &fragment)
|
||||
: props_(fragment.props ? fragment.props : sourceShadowNode.props_),
|
||||
:
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
revision_(sourceShadowNode.revision_ + 1),
|
||||
#endif
|
||||
props_(fragment.props ? fragment.props : sourceShadowNode.props_),
|
||||
children_(
|
||||
fragment.children ? fragment.children : sourceShadowNode.children_),
|
||||
localData_(
|
||||
@@ -67,8 +74,7 @@ ShadowNode::ShadowNode(
|
||||
fragment.state ? fragment.state
|
||||
: sourceShadowNode.getMostRecentState()),
|
||||
family_(sourceShadowNode.family_),
|
||||
childrenAreShared_(true),
|
||||
revision_(sourceShadowNode.revision_ + 1) {
|
||||
childrenAreShared_(true) {
|
||||
// `tag`, `surfaceId`, and `eventEmitter` cannot be changed with cloning.
|
||||
assert(fragment.tag == ShadowNodeFragment::tagPlaceholder());
|
||||
assert(fragment.surfaceId == ShadowNodeFragment::surfaceIdPlaceholder());
|
||||
|
||||
@@ -169,6 +169,13 @@ class ShadowNode : public virtual Sealable,
|
||||
std::string getDebugValue() const override;
|
||||
SharedDebugStringConvertibleList getDebugChildren() const override;
|
||||
SharedDebugStringConvertibleList getDebugProps() const override;
|
||||
|
||||
/*
|
||||
* A number of the generation of the ShadowNode instance;
|
||||
* is used and useful for debug-printing purposes *only*.
|
||||
* Do not access this value in any circumstances.
|
||||
*/
|
||||
int const revision_;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
@@ -194,13 +201,6 @@ class ShadowNode : public virtual Sealable,
|
||||
* to be cloned before the first mutation.
|
||||
*/
|
||||
bool childrenAreShared_;
|
||||
|
||||
/*
|
||||
* A number of the generation of the ShadowNode instance;
|
||||
* is used and useful for debug-printing purposes *only*.
|
||||
* Do not access this value in any circumstances.
|
||||
*/
|
||||
const int revision_;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
||||
Reference in New Issue
Block a user