Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t>(keyword);
}

constexpr Type type() const {
return static_cast<Type>(repr_ & kHandleTypeMask);
}
Expand Down
17 changes: 14 additions & 3 deletions packages/react-native/ReactCommon/yoga/yoga/style/StyleValuePool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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<uint32_t>(keyword);
}

void storeValue(
StyleValueHandle& handle,
float value,
Expand Down
Loading