diff options
Diffstat (limited to 'AK/StringBuilder.h')
-rw-r--r-- | AK/StringBuilder.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/AK/StringBuilder.h b/AK/StringBuilder.h index cc042e60de..d313c9147d 100644 --- a/AK/StringBuilder.h +++ b/AK/StringBuilder.h @@ -38,7 +38,7 @@ class StringBuilder { public: using OutputType = String; - explicit StringBuilder(size_t initial_capacity = 16); + explicit StringBuilder(size_t initial_capacity = inline_capacity); ~StringBuilder() { } void append(const StringView&); @@ -83,7 +83,12 @@ public: private: void will_append(size_t); + u8* data() { return m_buffer.is_null() ? m_inline_buffer : m_buffer.data(); } + const u8* data() const { return m_buffer.is_null() ? m_inline_buffer : m_buffer.data(); } + bool using_inline_buffer() const { return m_buffer.is_null(); } + static constexpr size_t inline_capacity = 128; + u8 m_inline_buffer[inline_capacity]; ByteBuffer m_buffer; size_t m_length { 0 }; }; |