mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Make ByteBuffer's trim helper public
This commit is contained in:
parent
29ecb2eda6
commit
2de582afc4
Notes:
sideshowbarker
2024-07-16 23:51:07 +09:00
Author: https://github.com/implicitfield Commit: https://github.com/SerenityOS/serenity/commit/2de582afc4 Pull-request: https://github.com/SerenityOS/serenity/pull/21954 Reviewed-by: https://github.com/alimpfard
1 changed files with 8 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue