diff --git a/packages/react-native/ReactCommon/yoga/yoga/style/StyleValueHandle.h b/packages/react-native/ReactCommon/yoga/yoga/style/StyleValueHandle.h index 6a2b58902339..ce622dd059fa 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/style/StyleValueHandle.h +++ b/packages/react-native/ReactCommon/yoga/yoga/style/StyleValueHandle.h @@ -76,10 +76,6 @@ class StyleValueHandle { // Intentionally leaving out auto as a fast path enum class Keyword : uint8_t { MaxContent, FitContent, Stretch }; - constexpr bool isKeyword(Keyword keyword) const { - return type() == Type::Keyword && value() == static_cast(keyword); - } - constexpr Type type() const { return static_cast(repr_ & kHandleTypeMask); } diff --git a/packages/react-native/ReactCommon/yoga/yoga/style/StyleValuePool.h b/packages/react-native/ReactCommon/yoga/yoga/style/StyleValuePool.h index fb31193b9789..c5846658ffb6 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/style/StyleValuePool.h +++ b/packages/react-native/ReactCommon/yoga/yoga/style/StyleValuePool.h @@ -89,11 +89,11 @@ class StyleValuePool { return StyleSizeLength::undefined(); } else if (handle.isAuto()) { return StyleSizeLength::ofAuto(); - } else if (handle.isKeyword(StyleValueHandle::Keyword::MaxContent)) { + } else if (isKeyword(handle, StyleValueHandle::Keyword::MaxContent)) { return StyleSizeLength::ofMaxContent(); - } else if (handle.isKeyword(StyleValueHandle::Keyword::FitContent)) { + } else if (isKeyword(handle, StyleValueHandle::Keyword::FitContent)) { return StyleSizeLength::ofFitContent(); - } else if (handle.isKeyword(StyleValueHandle::Keyword::Stretch)) { + } else if (isKeyword(handle, StyleValueHandle::Keyword::Stretch)) { return StyleSizeLength::ofStretch(); } else { assert( @@ -132,6 +132,17 @@ class StyleValuePool { } private: + bool isKeyword(StyleValueHandle handle, StyleValueHandle::Keyword keyword) + const { + if (handle.type() != StyleValueHandle::Type::Keyword) { + return false; + } + // storeKeyword() keeps an existing pool slot, so the keyword may be there + uint32_t value = handle.isValueIndexed() ? buffer_.get32(handle.value()) + : handle.value(); + return value == static_cast(keyword); + } + void storeValue( StyleValueHandle& handle, float value,