From 4023e4543986c2c0a4e2b87f0c764ceff73749eb Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Tue, 7 Nov 2023 11:54:44 -0800 Subject: [PATCH] Eliminate static const UndefinedColor from SharedColor (#41364) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41364 Initializing UndefinedColor on iOS and Android is trivial because the platform color is an int32_t. On platforms where the HostPlatformColor header defines a color as a struct (e.g., Windows) it is less trivial to compose a constexpr for the undefined color representation to initialize this static const value with. As it turns out, UndefinedColor is only used for operator bool in SharedColor, so it's reasonably safe to remove this "public" API (also good to limit the surface of SharedColor). ## Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D51073395 fbshipit-source-id: 375e43aa9a30d394d35ce2946224563738d8973c --- .../ReactCommon/react/renderer/graphics/Color.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/Color.h b/packages/react-native/ReactCommon/react/renderer/graphics/Color.h index bf00b003678..c3ae69eaa28 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/Color.h +++ b/packages/react-native/ReactCommon/react/renderer/graphics/Color.h @@ -25,9 +25,7 @@ namespace facebook::react { */ class SharedColor { public: - static const Color UndefinedColor = HostPlatformColor::UndefinedColor; - - SharedColor() : color_(UndefinedColor) {} + SharedColor() : color_(HostPlatformColor::UndefinedColor) {} SharedColor(Color color) : color_(color) {} @@ -44,7 +42,7 @@ class SharedColor { } operator bool() const { - return color_ != UndefinedColor; + return color_ != HostPlatformColor::UndefinedColor; } private: