1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:34:57 +00:00

AK: Replace ByteBuffer::grow with resize()/ensure_capacity()

Previously ByteBuffer::grow() behaved like Vector<T>::resize().
However the function name was somewhat ambiguous - and so this patch
updates ByteBuffer to behave more like Vector<T> by replacing grow()
with resize() and adding an ensure_capacity() method.

This also lets the user change the buffer's capacity without affecting
the size which was not previously possible.

Additionally this patch makes the capacity() method public (again).
This commit is contained in:
Gunnar Beutner 2021-05-31 00:31:46 +02:00 committed by Ali Mohammad Pur
parent dc54a0fbd3
commit 5f18cf75c5
7 changed files with 41 additions and 32 deletions

View file

@ -26,7 +26,7 @@ inline void StringBuilder::will_append(size_t size)
if (needed_capacity > inline_capacity)
expanded_capacity *= 2;
VERIFY(!expanded_capacity.has_overflow());
m_buffer.grow(expanded_capacity.value());
m_buffer.resize(expanded_capacity.value());
}
StringBuilder::StringBuilder(size_t initial_capacity)