AK: Convert StringBuilder to use east-const

This commit is contained in:
Timothy Flynn 2021-08-09 11:48:50 -04:00 committed by Andreas Kling
parent c1e99fca1a
commit 5978caf96b
Notes: sideshowbarker 2024-07-18 07:08:33 +09:00
2 changed files with 14 additions and 14 deletions

View File

@ -35,7 +35,7 @@ StringBuilder::StringBuilder(size_t initial_capacity)
m_buffer.ensure_capacity(initial_capacity);
}
void StringBuilder::append(const StringView& str)
void StringBuilder::append(StringView const& str)
{
if (str.is_empty())
return;
@ -43,7 +43,7 @@ void StringBuilder::append(const StringView& str)
m_buffer.append(str.characters_without_null_termination(), str.length());
}
void StringBuilder::append(const char* characters, size_t length)
void StringBuilder::append(char const* characters, size_t length)
{
append(StringView { characters, length });
}
@ -54,7 +54,7 @@ void StringBuilder::append(char ch)
m_buffer.append(&ch, 1);
}
void StringBuilder::appendvf(const char* fmt, va_list ap)
void StringBuilder::appendvf(char const* fmt, va_list ap)
{
printf_internal([this](char*&, char ch) {
append(ch);
@ -71,7 +71,7 @@ String StringBuilder::to_string() const
{
if (is_empty())
return String::empty();
return String((const char*)data(), length());
return String((char const*)data(), length());
}
String StringBuilder::build() const
@ -112,7 +112,7 @@ void StringBuilder::append_code_point(u32 code_point)
}
}
void StringBuilder::append(const Utf32View& utf32_view)
void StringBuilder::append(Utf32View const& utf32_view)
{
for (size_t i = 0; i < utf32_view.length(); ++i) {
auto code_point = utf32_view.code_points()[i];
@ -128,7 +128,7 @@ void StringBuilder::append_as_lowercase(char ch)
append(ch);
}
void StringBuilder::append_escaped_for_json(const StringView& string)
void StringBuilder::append_escaped_for_json(StringView const& string)
{
for (auto ch : string) {
switch (ch) {

View File

@ -21,18 +21,18 @@ public:
explicit StringBuilder(size_t initial_capacity = inline_capacity);
~StringBuilder() = default;
void append(const StringView&);
void append(const Utf32View&);
void append(StringView const&);
void append(Utf32View const&);
void append(char);
void append_code_point(u32);
void append(const char*, size_t);
void appendvf(const char*, va_list);
void append(char const*, size_t);
void appendvf(char const*, va_list);
void append_as_lowercase(char);
void append_escaped_for_json(const StringView&);
void append_escaped_for_json(StringView const&);
template<typename... Parameters>
void appendff(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters)
void appendff(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
{
vformat(*this, fmtstr.view(), VariadicFormatParams { parameters... });
}
@ -49,7 +49,7 @@ public:
void trim(size_t count) { m_buffer.resize(m_buffer.size() - count); }
template<class SeparatorType, class CollectionType>
void join(const SeparatorType& separator, const CollectionType& collection)
void join(SeparatorType const& separator, CollectionType const& collection)
{
bool first = true;
for (auto& item : collection) {
@ -64,7 +64,7 @@ public:
private:
void will_append(size_t);
u8* data() { return m_buffer.data(); }
const u8* data() const { return m_buffer.data(); }
u8 const* data() const { return m_buffer.data(); }
static constexpr size_t inline_capacity = 128;
AK::Detail::ByteBuffer<inline_capacity> m_buffer;