Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adjust RawPropsPropNameLength's type to account for increased number of props #39008

Closed
wants to merge 1 commit into from
Closed
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 @@ -38,6 +38,8 @@ void RawPropsKeyMap::insert(
item.value = value;
key.render(item.name, &item.length);
items_.push_back(item);
react_native_assert(
items_.size() < std::numeric_limits<RawPropsPropNameLength>::max());
}

void RawPropsKeyMap::reindex() noexcept {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ RawValue const *RawPropsParser::at(
// This is not thread-safe part; this happens only during initialization of
// a `ComponentDescriptor` where it is actually safe.
keys_.push_back(key);
react_native_assert(size < std::numeric_limits<RawPropsValueIndex>::max());
nameToIndex_.insert(key, static_cast<RawPropsValueIndex>(size));
return nullptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ namespace facebook::react {
/*
* Type used to represent an index of some stored values in small arrays.
*/
using RawPropsValueIndex = uint8_t;
using RawPropsValueIndex = uint16_t;
static_assert(
sizeof(RawPropsValueIndex) == 1,
"RawPropsValueIndex must be one byte size.");
using RawPropsPropNameLength = uint8_t;
sizeof(RawPropsValueIndex) == 2,
"RawPropsValueIndex must be two byte size.");
using RawPropsPropNameLength = uint16_t;
using RawPropsPropNameHash = uint32_t;

/*
Expand Down