mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-12 02:30:30 +09:00
AK: Improve the API of StringBuilder
This commit is contained in:
parent
0433c0780d
commit
d8df9c510c
Notes:
sideshowbarker
2024-07-19 17:37:15 +09:00
Author: https://github.com/f-eiwu
Commit: d8df9c510c
Pull-request: https://github.com/SerenityOS/serenity/pull/1386
Reviewed-by: https://github.com/awesomekling
2 changed files with 9 additions and 9 deletions
|
@ -85,19 +85,19 @@ void StringBuilder::appendf(const char* fmt, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuffer StringBuilder::to_byte_buffer()
|
ByteBuffer StringBuilder::to_byte_buffer() const
|
||||||
{
|
{
|
||||||
m_buffer.trim(m_length);
|
ByteBuffer buffer_copy = m_buffer.isolated_copy();
|
||||||
m_length = 0;
|
buffer_copy.trim(m_length);
|
||||||
return move(m_buffer);
|
return buffer_copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
String StringBuilder::to_string()
|
String StringBuilder::to_string() const
|
||||||
{
|
{
|
||||||
return String((const char*)m_buffer.data(), m_length);
|
return String((const char*)m_buffer.data(), m_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
String StringBuilder::build()
|
String StringBuilder::build() const
|
||||||
{
|
{
|
||||||
return to_string();
|
return to_string();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,9 @@ public:
|
||||||
void appendf(const char*, ...);
|
void appendf(const char*, ...);
|
||||||
void appendvf(const char*, va_list);
|
void appendvf(const char*, va_list);
|
||||||
|
|
||||||
String build();
|
String build() const;
|
||||||
String to_string();
|
String to_string() const;
|
||||||
ByteBuffer to_byte_buffer();
|
ByteBuffer to_byte_buffer() const;
|
||||||
|
|
||||||
StringView string_view() const;
|
StringView string_view() const;
|
||||||
void clear();
|
void clear();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue