mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09: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
Notes:
sideshowbarker
2024-07-19 13:22:02 +09:00
Author: https://github.com/awesomekling
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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue