Skip to content

Commit 0485cab

Browse files
committed
Adjust RawPropsPropNameLength's type to account for increased number of props (facebook#39008)
Summary: Pull Request resolved: facebook#39008 Changelog: [Internal] - Adjust RawPropsPropNameLength's type to account for increased number of props While investigating why we needed to back out D48288752 I discovered that the root cause was that the `items_` vector in `RawProsKeyMap` was now a size greater than 255 which becomes an issue because `items_`'s indices are statically cast to `RawPropsPropNameLength` (previously alias to `uint8_t`). This diff updates `RawPropsPropNameLength` to be an alias to `uint16_t` so the current issue is resolved as well as adding an assert to ensure (however unlikely) that this happens again. Differential Revision: D48331909 fbshipit-source-id: e89f4c1dce36e63dc9c395eca4ff47b18b5f5e12
1 parent 857bc05 commit 0485cab

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/react-native/ReactCommon/react/renderer/core/RawPropsKeyMap.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ void RawPropsKeyMap::insert(
3838
item.value = value;
3939
key.render(item.name, &item.length);
4040
items_.push_back(item);
41+
react_native_assert(
42+
items_.size() < std::numeric_limits<RawPropsPropNameLength>::max());
4143
}
4244

4345
void RawPropsKeyMap::reindex() noexcept {

packages/react-native/ReactCommon/react/renderer/core/RawPropsPrimitives.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using RawPropsValueIndex = uint8_t;
1919
static_assert(
2020
sizeof(RawPropsValueIndex) == 1,
2121
"RawPropsValueIndex must be one byte size.");
22-
using RawPropsPropNameLength = uint8_t;
22+
using RawPropsPropNameLength = uint16_t;
2323
using RawPropsPropNameHash = uint32_t;
2424

2525
/*

0 commit comments

Comments
 (0)