AK: Use StringBuilder::appendff() instead of appendf()

This commit is contained in:
Andreas Kling 2021-02-09 16:08:11 +01:00
parent db0149056f
commit 764af6cdec
Notes: sideshowbarker 2024-07-18 22:28:32 +09:00
4 changed files with 11 additions and 11 deletions

View file

@ -73,7 +73,7 @@ String encode_hex(ReadonlyBytes input)
StringBuilder output(input.size() * 2);
for (auto ch : input)
output.appendf("%02x", ch);
output.appendff("{:02x}", ch);
return output.build();
}

View file

@ -172,7 +172,7 @@ inline void JsonValue::serialize(Builder& builder) const
break;
#if !defined(KERNEL)
case Type::Double:
builder.appendf("%g", m_value.as_double);
builder.appendff("{}", m_value.as_double);
break;
#endif
case Type::Int32:

View file

@ -88,43 +88,43 @@ public:
void add(const StringView& key, int value)
{
begin_item(key);
m_builder.appendf("%d", value);
m_builder.appendff("{}", value);
}
void add(const StringView& key, unsigned value)
{
begin_item(key);
m_builder.appendf("%u", value);
m_builder.appendff("{}", value);
}
void add(const StringView& key, long value)
{
begin_item(key);
m_builder.appendf("%ld", value);
m_builder.appendff("{}", value);
}
void add(const StringView& key, long unsigned value)
{
begin_item(key);
m_builder.appendf("%lu", value);
m_builder.appendff("{}", value);
}
void add(const StringView& key, long long value)
{
begin_item(key);
m_builder.appendf("%lld", value);
m_builder.appendff("{}", value);
}
void add(const StringView& key, long long unsigned value)
{
begin_item(key);
m_builder.appendf("%llu", value);
m_builder.appendff("{}", value);
}
void add(const StringView& key, double value)
{
begin_item(key);
m_builder.appendf("%f", value);
m_builder.appendff("{}", value);
}
JsonArraySerializer<Builder> add_array(const StringView& key)

View file

@ -207,9 +207,9 @@ void dump_bytes(ReadonlyBytes bytes)
auto flush = [&]() {
if (nrepeat > 0) {
if (nrepeat == 1)
builder.appendf("%s0x%02x", prefix, static_cast<int>(buffered_byte));
builder.appendff("{}{:#02x}", prefix, static_cast<int>(buffered_byte));
else
builder.appendf("%s%zu * 0x%02x", prefix, nrepeat, static_cast<int>(buffered_byte));
builder.appendff("{}{} * {:#02x}", prefix, nrepeat, static_cast<int>(buffered_byte));
nrepeat = 0;
prefix = ", ";