Add uint reading method to BufferWithExtendableBuffer.
Bug: 11073222 Change-Id: Iff503cba883dd6f4ce9079783ad6a2edf464ffbamain
parent
41b77116d3
commit
b8a1e8fa33
|
@ -23,6 +23,20 @@ const int BufferWithExtendableBuffer::NEAR_BUFFER_LIMIT_THRESHOLD_PERCENTILE = 9
|
||||||
// TODO: Needs to allocate larger memory corresponding to the current vector size.
|
// TODO: Needs to allocate larger memory corresponding to the current vector size.
|
||||||
const size_t BufferWithExtendableBuffer::EXTEND_ADDITIONAL_BUFFER_SIZE_STEP = 128 * 1024;
|
const size_t BufferWithExtendableBuffer::EXTEND_ADDITIONAL_BUFFER_SIZE_STEP = 128 * 1024;
|
||||||
|
|
||||||
|
uint32_t BufferWithExtendableBuffer::readUintAndAdvancePosition(const int size,
|
||||||
|
int *const pos) const {
|
||||||
|
const bool readingPosIsInAdditionalBuffer = isInAdditionalBuffer(*pos);
|
||||||
|
if (readingPosIsInAdditionalBuffer) {
|
||||||
|
*pos -= mOriginalBufferSize;
|
||||||
|
}
|
||||||
|
const int value = ByteArrayUtils::readUintAndAdvancePosition(
|
||||||
|
getBuffer(readingPosIsInAdditionalBuffer), size, pos);
|
||||||
|
if (readingPosIsInAdditionalBuffer) {
|
||||||
|
*pos += mOriginalBufferSize;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
bool BufferWithExtendableBuffer::writeUintAndAdvancePosition(const uint32_t data, const int size,
|
bool BufferWithExtendableBuffer::writeUintAndAdvancePosition(const uint32_t data, const int size,
|
||||||
int *const pos) {
|
int *const pos) {
|
||||||
if (!(size >= 1 && size <= 4)) {
|
if (!(size >= 1 && size <= 4)) {
|
||||||
|
|
|
@ -71,6 +71,8 @@ class BufferWithExtendableBuffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t readUintAndAdvancePosition(const int size, int *const pos) const;
|
||||||
|
|
||||||
AK_FORCE_INLINE int getOriginalBufferSize() const {
|
AK_FORCE_INLINE int getOriginalBufferSize() const {
|
||||||
return mOriginalBufferSize;
|
return mOriginalBufferSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,24 @@ class ByteArrayUtils {
|
||||||
return buffer[(*pos)++];
|
return buffer[(*pos)++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static AK_FORCE_INLINE int readUintAndAdvancePosition(const uint8_t *const buffer,
|
||||||
|
const int size, int *const pos) {
|
||||||
|
// size must be in 1 to 4.
|
||||||
|
ASSERT(size >= 1 && size <= 4);
|
||||||
|
switch (size) {
|
||||||
|
case 1:
|
||||||
|
return ByteArrayUtils::readUint8AndAdvancePosition(buffer, pos);
|
||||||
|
case 2:
|
||||||
|
return ByteArrayUtils::readUint16AndAdvancePosition(buffer, pos);
|
||||||
|
case 3:
|
||||||
|
return ByteArrayUtils::readUint24AndAdvancePosition(buffer, pos);
|
||||||
|
case 4:
|
||||||
|
return ByteArrayUtils::readUint32AndAdvancePosition(buffer, pos);
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code Point Reading
|
* Code Point Reading
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue