File tree Expand file tree Collapse file tree
packages/react-native/ReactCommon/yoga/yoga/style Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,10 +76,6 @@ class StyleValueHandle {
7676 // Intentionally leaving out auto as a fast path
7777 enum class Keyword : uint8_t { MaxContent, FitContent, Stretch };
7878
79- constexpr bool isKeyword (Keyword keyword) const {
80- return type () == Type::Keyword && value () == static_cast <uint16_t >(keyword);
81- }
82-
8379 constexpr Type type () const {
8480 return static_cast <Type>(repr_ & kHandleTypeMask );
8581 }
Original file line number Diff line number Diff line change @@ -89,11 +89,11 @@ class StyleValuePool {
8989 return StyleSizeLength::undefined ();
9090 } else if (handle.isAuto ()) {
9191 return StyleSizeLength::ofAuto ();
92- } else if (handle. isKeyword (StyleValueHandle::Keyword::MaxContent)) {
92+ } else if (isKeyword (handle, StyleValueHandle::Keyword::MaxContent)) {
9393 return StyleSizeLength::ofMaxContent ();
94- } else if (handle. isKeyword (StyleValueHandle::Keyword::FitContent)) {
94+ } else if (isKeyword (handle, StyleValueHandle::Keyword::FitContent)) {
9595 return StyleSizeLength::ofFitContent ();
96- } else if (handle. isKeyword (StyleValueHandle::Keyword::Stretch)) {
96+ } else if (isKeyword (handle, StyleValueHandle::Keyword::Stretch)) {
9797 return StyleSizeLength::ofStretch ();
9898 } else {
9999 assert (
@@ -132,6 +132,17 @@ class StyleValuePool {
132132 }
133133
134134 private:
135+ bool isKeyword (StyleValueHandle handle, StyleValueHandle::Keyword keyword)
136+ const {
137+ if (handle.type () != StyleValueHandle::Type::Keyword) {
138+ return false ;
139+ }
140+ // storeKeyword() keeps an existing pool slot, so the keyword may be there
141+ uint32_t value = handle.isValueIndexed () ? buffer_.get32 (handle.value ())
142+ : handle.value ();
143+ return value == static_cast <uint32_t >(keyword);
144+ }
145+
135146 void storeValue (
136147 StyleValueHandle& handle,
137148 float value,
You can’t perform that action at this time.
0 commit comments