AK: Use StringView literals in Format to avoid strlen

We don't want to be constructing StringViews at runtime if we don't have
to in Formatter code.
This commit is contained in:
Andrew Kaster 2021-07-17 16:05:18 -06:00 committed by Ali Mohammad Pur
parent e49af4bac9
commit 4842c8c902
Notes: sideshowbarker 2024-07-18 08:46:22 +09:00
2 changed files with 4 additions and 4 deletions

View File

@ -442,7 +442,7 @@ void FormatBuilder::put_hexdump(ReadonlyBytes bytes, size_t width, char fill)
if (width > 0) {
if (i % width == 0 && i) {
put_char_view(i);
put_literal("\n");
put_literal("\n"sv);
}
}
put_u64(bytes[i], 16, false, false, true, Align::Right, 2);

View File

@ -351,15 +351,15 @@ requires(HasFormatter<T>) struct Formatter<Vector<T>> : StandardFormatter {
m_precision = m_precision.value_or(NumericLimits<size_t>::max());
Formatter<T> content_fmt;
builder.put_literal("[ ");
builder.put_literal("[ "sv);
bool first = true;
for (auto& content : value) {
if (!first)
builder.put_literal(", ");
builder.put_literal(", "sv);
first = false;
content_fmt.format(builder, content);
}
builder.put_literal(" ]");
builder.put_literal(" ]"sv);
}
};