mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
AK: Add a fallible StringBuilder::create() factory function
This is nice, and is also used by the Jakt runtime.
This commit is contained in:
parent
21c2d8bd98
commit
543890c5c9
2 changed files with 9 additions and 0 deletions
|
@ -36,6 +36,13 @@ inline ErrorOr<void> StringBuilder::will_append(size_t size)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<StringBuilder> StringBuilder::create(size_t initial_capacity)
|
||||
{
|
||||
StringBuilder builder;
|
||||
TRY(builder.m_buffer.try_ensure_capacity(initial_capacity));
|
||||
return builder;
|
||||
}
|
||||
|
||||
StringBuilder::StringBuilder(size_t initial_capacity)
|
||||
{
|
||||
m_buffer.ensure_capacity(initial_capacity);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue