From 6bc7ef0b19be3d1e5ee4c99106d2d0c08be82b11 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Fri, 1 Mar 2019 22:07:27 -0800 Subject: [PATCH] Fabric: Props now have a revision number Summary: Props now have a special value that represents generation number of `Props` object, which increases when the object was constructed with some source `Props` object. Reviewed By: mdvacca Differential Revision: D14293939 fbshipit-source-id: 4782bf33ccf37623d4079c09cc4d0268bb6c2690 --- ReactCommon/fabric/core/shadownode/Props.cpp | 3 ++- ReactCommon/fabric/core/shadownode/Props.h | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ReactCommon/fabric/core/shadownode/Props.cpp b/ReactCommon/fabric/core/shadownode/Props.cpp index d56726f7bd5..d3969cdcb80 100644 --- a/ReactCommon/fabric/core/shadownode/Props.cpp +++ b/ReactCommon/fabric/core/shadownode/Props.cpp @@ -14,7 +14,8 @@ namespace facebook { namespace react { Props::Props(const Props &sourceProps, const RawProps &rawProps) - : nativeId(convertRawProp(rawProps, "nativeID", sourceProps.nativeId)) + : nativeId(convertRawProp(rawProps, "nativeID", sourceProps.nativeId)), + revision(sourceProps.revision + 1) #ifdef ANDROID , rawProps((folly::dynamic)rawProps) diff --git a/ReactCommon/fabric/core/shadownode/Props.h b/ReactCommon/fabric/core/shadownode/Props.h index 840ef84ade9..56362dddf87 100644 --- a/ReactCommon/fabric/core/shadownode/Props.h +++ b/ReactCommon/fabric/core/shadownode/Props.h @@ -31,6 +31,15 @@ class Props : public virtual Sealable, public virtual DebugStringConvertible { const std::string nativeId; + /* + * Special value that represents generation number of `Props` object, which + * increases when the object was constructed with some source `Props` object. + * Default props objects (that was constructed using default constructor) have + * revision equals `0`. + * The value might be used for optimization purposes. + */ + const int revision{0}; + #ifdef ANDROID const folly::dynamic rawProps = folly::dynamic::object(); #endif