mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 09:07:44 +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:
parent
0e75aba7c3
commit
2caec95d30
1 changed files with 2 additions and 0 deletions
|
@ -61,6 +61,7 @@ void StringBuilder::appendf(const char* fmt, ...)
|
||||||
ByteBuffer StringBuilder::to_byte_buffer()
|
ByteBuffer StringBuilder::to_byte_buffer()
|
||||||
{
|
{
|
||||||
m_buffer.trim(m_length);
|
m_buffer.trim(m_length);
|
||||||
|
m_length = 0;
|
||||||
return move(m_buffer);
|
return move(m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ String StringBuilder::to_string()
|
||||||
{
|
{
|
||||||
auto string = String((const char*)m_buffer.pointer(), m_length);
|
auto string = String((const char*)m_buffer.pointer(), m_length);
|
||||||
m_buffer.clear();
|
m_buffer.clear();
|
||||||
|
m_length = 0;
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue