mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-23 13:57:04 +00:00
StringBuilder: Reset the internal builder length after building.
This puts the StringBuilder back into a pristine state, allowing you to use it to build more strings after you've built one.
This commit is contained in:
@@ -61,6 +61,7 @@ void StringBuilder::appendf(const char* fmt, ...)
|
||||
ByteBuffer StringBuilder::to_byte_buffer()
|
||||
{
|
||||
m_buffer.trim(m_length);
|
||||
m_length = 0;
|
||||
return move(m_buffer);
|
||||
}
|
||||
|
||||
@@ -68,6 +69,7 @@ String StringBuilder::to_string()
|
||||
{
|
||||
auto string = String((const char*)m_buffer.pointer(), m_length);
|
||||
m_buffer.clear();
|
||||
m_length = 0;
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user