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:
parent
e49af4bac9
commit
4842c8c902
Notes:
sideshowbarker
2024-07-18 08:46:22 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/4842c8c9028 Pull-request: https://github.com/SerenityOS/serenity/pull/8845 Reviewed-by: https://github.com/alimpfard
2 changed files with 4 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue