mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Allow random stores and accesses to MapBuffer values
Summary: Removes the need to store keys in incremental order by sorting them after before inserting into MapBuffer. Updates MapBuffer to support random access on C++ side, actually retrieving values by keys and not bucket index. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D33611758 fbshipit-source-id: c81e970613c8ecc688bfacb29ba038bf081a0c0f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1ec399781d
commit
d287598d23
@@ -166,3 +166,20 @@ TEST(MapBufferTest, testMapEntries) {
|
||||
EXPECT_EQ(readMap2.getString(0), "This is a test");
|
||||
EXPECT_EQ(readMap2.getInt(1), 1234);
|
||||
}
|
||||
|
||||
TEST(MapBufferTest, testMapRandomAccess) {
|
||||
auto builder = MapBufferBuilder();
|
||||
builder.putInt(1234, 4321);
|
||||
builder.putString(0, "This is a test");
|
||||
builder.putDouble(8, 908.1);
|
||||
builder.putNull(2);
|
||||
builder.putString(65535, "Let's count: 的, 一, 是");
|
||||
auto map = builder.build();
|
||||
|
||||
EXPECT_EQ(map.count(), 5);
|
||||
EXPECT_EQ(map.getString(0), "This is a test");
|
||||
EXPECT_EQ(map.getDouble(8), 908.1);
|
||||
EXPECT_EQ(map.isNull(2), true);
|
||||
EXPECT_EQ(map.getInt(1234), 4321);
|
||||
EXPECT_EQ(map.getString(65535), "Let's count: 的, 一, 是");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user