AK: Make ByteBuffer's trim helper public

This commit is contained in:
implicitfield 2023-11-18 10:53:53 +04:00 committed by Ali Mohammad Pur
parent 29ecb2eda6
commit 2de582afc4
Notes: sideshowbarker 2024-07-16 23:51:07 +09:00

View file

@ -168,6 +168,14 @@ public:
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));
@ -282,14 +290,6 @@ private:
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