From 27b672993d40cae05db2a85ddbb8f138a25cd923 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Sun, 23 Jun 2019 21:30:00 -0700 Subject: [PATCH] Fabric: Unification of ShadowView's default constructor Summary: The previous version of a set of default values of `ShadowView`'s fields has a bug: ``` ComponentName componentName = ""; ``` Initalizing `char const *` with a string literal in .h file makes the default constructor of the object produces different values across binary units (because a pointer to empty string can be defined differently). Now it's just a null pointer. Reviewed By: sammy-SC Differential Revision: D15911452 fbshipit-source-id: 16bcfb5f78ea802c0833135c486e3fbb8b7acaa6 --- ReactCommon/fabric/mounting/ShadowView.h | 28 +++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/ReactCommon/fabric/mounting/ShadowView.h b/ReactCommon/fabric/mounting/ShadowView.h index 1746c90fd28..325bd744f43 100644 --- a/ReactCommon/fabric/mounting/ShadowView.h +++ b/ReactCommon/fabric/mounting/ShadowView.h @@ -22,30 +22,28 @@ namespace react { */ struct ShadowView final { ShadowView() = default; - ShadowView(const ShadowView &shadowView) = default; + ShadowView(ShadowView const &shadowView) = default; ShadowView(ShadowView &&shadowView) noexcept = default; - ~ShadowView(){}; - /* * Constructs a `ShadowView` from given `ShadowNode`. */ - explicit ShadowView(const ShadowNode &shadowNode); + explicit ShadowView(ShadowNode const &shadowNode); - ShadowView &operator=(const ShadowView &other) = default; + ShadowView &operator=(ShadowView const &other) = default; ShadowView &operator=(ShadowView &&other) = default; - bool operator==(const ShadowView &rhs) const; - bool operator!=(const ShadowView &rhs) const; + bool operator==(ShadowView const &rhs) const; + bool operator!=(ShadowView const &rhs) const; - ComponentName componentName = ""; - ComponentHandle componentHandle = 0; - Tag tag = -1; // Tag does not change during the lifetime of a shadow view. - SharedProps props = {}; - SharedEventEmitter eventEmitter = {}; - LayoutMetrics layoutMetrics = EmptyLayoutMetrics; - SharedLocalData localData = {}; - State::Shared state = {}; + ComponentName componentName{}; + ComponentHandle componentHandle{}; + Tag tag{}; + Props::Shared props{}; + EventEmitter::Shared eventEmitter{}; + LayoutMetrics layoutMetrics{EmptyLayoutMetrics}; + LocalData::Shared localData{}; + State::Shared state{}; }; #if RN_DEBUG_STRING_CONVERTIBLE