mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 21:54:40 +03:00
AK: Convert StringBuilder to use east-const
This commit is contained in:
parent
c1e99fca1a
commit
5978caf96b
Notes:
sideshowbarker
2024-07-18 07:08:33 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/5978caf96bc Pull-request: https://github.com/SerenityOS/serenity/pull/9320 Reviewed-by: https://github.com/davidot ✅
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user