mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Refactor dataSize to use int instead of short
Summary: DynamicData can contain a big amount of data, refactoring type to use int instead of short changelog: [internal] internal Reviewed By: sammy-SC Differential Revision: D27904643 fbshipit-source-id: 157064b280e27a9c7c4a4f55af310392b178feda
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f946001c4e
commit
668d71aa0b
+4
-4
@@ -29,8 +29,8 @@ public class ReadableMapBuffer implements Iterable<ReadableMapBuffer.MapBufferEn
|
||||
// Value used to verify if the data is serialized with LittleEndian order.
|
||||
private static final int ALIGNMENT = 0xFE;
|
||||
|
||||
// 6 bytes = 2 (alignment) + 2 (count) + 2 (size)
|
||||
private static final int HEADER_SIZE = 6;
|
||||
// 8 bytes = 2 (alignment) + 2 (count) + 4 (size)
|
||||
private static final int HEADER_SIZE = 8;
|
||||
|
||||
// key size = 2 bytes
|
||||
private static final int KEY_SIZE = 2;
|
||||
@@ -50,7 +50,7 @@ public class ReadableMapBuffer implements Iterable<ReadableMapBuffer.MapBufferEn
|
||||
|
||||
// Size of the Serialized Data
|
||||
@SuppressWarnings("unused")
|
||||
private short mSizeOfData = 0;
|
||||
private int mSizeOfData = 0;
|
||||
|
||||
// Amount of items serialized on the ByteBuffer
|
||||
@SuppressWarnings("unused")
|
||||
@@ -178,7 +178,7 @@ public class ReadableMapBuffer implements Iterable<ReadableMapBuffer.MapBufferEn
|
||||
// count
|
||||
mCount = mBuffer.getShort();
|
||||
// size
|
||||
mSizeOfData = mBuffer.getShort();
|
||||
mSizeOfData = mBuffer.getInt();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace react {
|
||||
|
||||
// TODO T83483191: Extend MapBuffer C++ implementation to support basic random
|
||||
// access
|
||||
MapBuffer::MapBuffer(uint8_t *const data, uint16_t dataSize) {
|
||||
MapBuffer::MapBuffer(uint8_t *const data, int dataSize) {
|
||||
react_native_assert(
|
||||
(data != nullptr) && "Error trying to build an invalid MapBuffer");
|
||||
|
||||
@@ -33,7 +33,7 @@ MapBuffer::MapBuffer(uint8_t *const data, uint16_t dataSize) {
|
||||
memcpy(
|
||||
reinterpret_cast<uint8_t *>(&dataSize_),
|
||||
reinterpret_cast<const uint8_t *>(data_ + HEADER_BUFFER_SIZE_OFFSET),
|
||||
UINT16_SIZE);
|
||||
INT_SIZE);
|
||||
|
||||
if (dataSize != dataSize_) {
|
||||
LOG(ERROR) << "Error: Data size does not match, expected " << dataSize
|
||||
@@ -123,7 +123,7 @@ bool MapBuffer::isNull(Key key) const {
|
||||
return getInt(key) == NULL_VALUE;
|
||||
}
|
||||
|
||||
uint16_t MapBuffer::getBufferSize() const {
|
||||
int MapBuffer::getBufferSize() const {
|
||||
return dataSize_;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class MapBuffer {
|
||||
const uint8_t *data_ = nullptr;
|
||||
|
||||
// amount of bytes in the MapBuffer
|
||||
uint16_t dataSize_ = 0;
|
||||
int dataSize_ = 0;
|
||||
|
||||
// amount of items in the MapBuffer
|
||||
uint16_t count_ = 0;
|
||||
@@ -46,7 +46,7 @@ class MapBuffer {
|
||||
int getDynamicDataOffset() const;
|
||||
|
||||
public:
|
||||
MapBuffer(uint8_t *const data, uint16_t dataSize);
|
||||
MapBuffer(uint8_t *const data, int dataSize);
|
||||
|
||||
~MapBuffer();
|
||||
|
||||
@@ -61,7 +61,7 @@ class MapBuffer {
|
||||
// TODO T83483191: review this declaration
|
||||
MapBuffer getMapBuffer(Key key) const;
|
||||
|
||||
uint16_t getBufferSize() const;
|
||||
int getBufferSize() const;
|
||||
|
||||
// TODO T83483191: review parameters of copy method
|
||||
void copy(uint8_t *output) const;
|
||||
|
||||
@@ -141,7 +141,7 @@ void MapBufferBuilder::putString(Key key, std::string value) {
|
||||
}
|
||||
|
||||
void MapBufferBuilder::putMapBuffer(Key key, MapBuffer &map) {
|
||||
uint16_t mapBufferSize = map.getBufferSize();
|
||||
int mapBufferSize = map.getBufferSize();
|
||||
|
||||
// format [lenght of buffer (short)] + [Array of Characters in the string]
|
||||
int sizeOfDynamicData = mapBufferSize + UINT16_SIZE;
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace facebook {
|
||||
namespace react {
|
||||
|
||||
// Default initial size for _keyValues array
|
||||
// 106 = 10 entries = 10*10 + 6 sizeof(header)
|
||||
constexpr uint16_t INITIAL_KEY_VALUE_SIZE = 106;
|
||||
// 108 = 10 entries = 10*10 + 8 sizeof(header)
|
||||
constexpr uint16_t INITIAL_KEY_VALUE_SIZE = 108;
|
||||
|
||||
// Default initial size for _dynamicDataValues array
|
||||
constexpr int INITIAL_DYNAMIC_DATA_SIZE = 200;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace react {
|
||||
struct Header {
|
||||
uint16_t alignment; // alignment of serialization
|
||||
uint16_t count; // amount of items in the map
|
||||
uint16_t bufferSize; // Amount of bytes used to store the map in memory
|
||||
int bufferSize; // Amount of bytes used to store the map in memory
|
||||
};
|
||||
|
||||
constexpr static int KEY_SIZE = sizeof(Key);
|
||||
|
||||
Reference in New Issue
Block a user