summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-05-12 21:40:29 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-13 08:27:42 +0200
commit93c3b6bdd249f6410f18be782fb12a9451ebf7c7 (patch)
tree7967b170792bd913afe7a351a88df45104ba819b /Kernel
parent1bb20a255fd0b7196250bb2b984407333e5983dd (diff)
downloadserenity-93c3b6bdd249f6410f18be782fb12a9451ebf7c7.zip
Kernel: Avoid allocations in KBufferBuilder::appendff
This avoids some of the the shortest-lived allocations in the kernel: StringImpl::create_uninitialized(unsigned long, char*&) StringImpl::create(char const*, unsigned long, ShouldChomp) StringBuilder::to_string() const String::vformatted(StringView, TypeErasedFormatParams) void Kernel::KBufferBuilder::appendff<unsigned int>(...) JsonObjectSerializer<Kernel::KBufferBuilder>::add(..., unsigned int) Kernel::procfs$all(Kernel::InodeIdentifier, ...) const Kernel::procfs$all(Kernel::InodeIdentifier, Kernel::KBufferBuilder&)
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/KBufferBuilder.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/Kernel/KBufferBuilder.h b/Kernel/KBufferBuilder.h
index 106d9d9155..4ab6b1527d 100644
--- a/Kernel/KBufferBuilder.h
+++ b/Kernel/KBufferBuilder.h
@@ -33,7 +33,9 @@ public:
{
// FIXME: This is really not the way to go about it, but vformat expects a
// StringBuilder. Why does this class exist anyways?
- append(String::formatted(fmtstr.view(), parameters...));
+ StringBuilder builder;
+ vformat(builder, fmtstr.view(), AK::VariadicFormatParams { parameters... });
+ append_bytes(builder.string_view().bytes());
}
bool flush();