Skip to content

Commit

Permalink
AK: Make ByteBuffer's trim helper public
Browse files Browse the repository at this point in the history
  • Loading branch information
implicitfield authored and alimpfard committed Dec 8, 2023
1 parent 29ecb2e commit 2de582a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions AK/ByteBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ class ByteBuffer {
MUST(try_resize(new_size));
}

void trim(size_t size, bool may_discard_existing_data)
{
VERIFY(size <= m_size);
if (!m_inline && size <= inline_capacity)
shrink_into_inline_buffer(size, may_discard_existing_data);
m_size = size;
}

ALWAYS_INLINE void ensure_capacity(size_t new_capacity)
{
MUST(try_ensure_capacity(new_capacity));
Expand Down Expand Up @@ -282,14 +290,6 @@ class ByteBuffer {
other.m_inline = true;
}

void trim(size_t size, bool may_discard_existing_data)
{
VERIFY(size <= m_size);
if (!m_inline && size <= inline_capacity)
shrink_into_inline_buffer(size, may_discard_existing_data);
m_size = size;
}

NEVER_INLINE void shrink_into_inline_buffer(size_t size, bool may_discard_existing_data)
{
// m_inline_buffer and m_outline_buffer are part of a union, so save the pointer
Expand Down

0 comments on commit 2de582a

Please sign in to comment.