1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-10-31 15:22:43 +00:00

LibDebug: Use InputMemoryStream instead of BufferStream.

This removes another call to ByteBuffer::wrap(const void*, size_t).
This commit is contained in:
asynts 2020-08-05 10:55:36 +02:00 committed by Andreas Kling
parent 5bfa7749c3
commit ac9f6fd1f8
12 changed files with 125 additions and 106 deletions

View file

@ -352,50 +352,6 @@ public:
return *this;
}
// LEB128 is a variable-length encoding for integers
BufferStream& read_LEB128_unsigned(size_t& result)
{
result = 0;
size_t num_bytes = 0;
while (true) {
if (m_offset > m_buffer.size()) {
m_read_failure = true;
break;
}
const u8 byte = m_buffer[m_offset];
result = (result) | (static_cast<size_t>(byte & ~(1 << 7)) << (num_bytes * 7));
++m_offset;
if (!(byte & (1 << 7)))
break;
++num_bytes;
}
return *this;
}
// LEB128 is a variable-length encoding for integers
BufferStream& read_LEB128_signed(ssize_t& result)
{
result = 0;
size_t num_bytes = 0;
u8 byte = 0;
do {
if (m_offset > m_buffer.size()) {
m_read_failure = true;
break;
}
byte = m_buffer[m_offset];
result = (result) | (static_cast<size_t>(byte & ~(1 << 7)) << (num_bytes * 7));
++m_offset;
++num_bytes;
} while (byte & (1 << 7));
if (num_bytes * 7 < sizeof(size_t) * 4 && (byte & 0x40)) {
// sign extend
result |= ((size_t)(-1) << (num_bytes * 7));
}
return *this;
}
BufferStream& advance(size_t amount)
{
if (m_offset + amount > m_buffer.size()) {