mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +00:00
VFS: Resolve FIXME in Inode::read_entire() about using dynamic allocation.
This commit is contained in:
parent
f83a94ca39
commit
cc906a2897
3 changed files with 20 additions and 8 deletions
|
@ -11,6 +11,11 @@ inline void StringBuilder::will_append(size_t size)
|
|||
m_buffer.grow(max(16u, m_buffer.size() * 2 + size));
|
||||
}
|
||||
|
||||
StringBuilder::StringBuilder(size_t initial_capacity)
|
||||
{
|
||||
m_buffer.grow(initial_capacity);
|
||||
}
|
||||
|
||||
void StringBuilder::append(const String& str)
|
||||
{
|
||||
if (str.is_empty())
|
||||
|
@ -20,6 +25,15 @@ void StringBuilder::append(const String& str)
|
|||
m_length += str.length();
|
||||
}
|
||||
|
||||
void StringBuilder::append(const char* characters, size_t length)
|
||||
{
|
||||
if (!length)
|
||||
return;
|
||||
will_append(length);
|
||||
memcpy(m_buffer.pointer() + m_length, characters, length);
|
||||
m_length += length;
|
||||
}
|
||||
|
||||
void StringBuilder::append(char ch)
|
||||
{
|
||||
will_append(1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue