From 018c4e0e7e54ad49d365ba1463cbc6dc83ea02e7 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Sat, 4 Sep 2021 21:28:45 +0200 Subject: [PATCH] AK+Kernel: Format DistinctNumeric using the underlying type's formatter Forcing the formatting to go through `Formatter` is completely unnecessary, increases code size, performs a String allocation and prevents us from using the formatting options available on that type. This commit also removes explicit formatters from `BlockBasedFileSystem::BlockIndex` and `Kernel::InodeIndex`, as those are already covered by the blanket implementation for all `DistinctNumeric` types. --- AK/DistinctNumeric.h | 4 ++-- Kernel/FileSystem/BlockBasedFileSystem.h | 8 -------- Kernel/FileSystem/InodeIdentifier.h | 8 -------- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/AK/DistinctNumeric.h b/AK/DistinctNumeric.h index 8a5321143aa..77bb7058d7f 100644 --- a/AK/DistinctNumeric.h +++ b/AK/DistinctNumeric.h @@ -270,10 +270,10 @@ private: }; template -struct Formatter> : Formatter { +struct Formatter> : Formatter { void format(FormatBuilder& builder, DistinctNumeric value) { - return Formatter::format(builder, "{}", value.value()); + return Formatter::format(builder, value.value()); } }; diff --git a/Kernel/FileSystem/BlockBasedFileSystem.h b/Kernel/FileSystem/BlockBasedFileSystem.h index 12f8d4ee9d9..2e62f652d47 100644 --- a/Kernel/FileSystem/BlockBasedFileSystem.h +++ b/Kernel/FileSystem/BlockBasedFileSystem.h @@ -48,11 +48,3 @@ private: }; } - -template<> -struct AK::Formatter : AK::Formatter { - void format(FormatBuilder& builder, Kernel::BlockBasedFileSystem::BlockIndex value) - { - return AK::Formatter::format(builder, "{}", value.value()); - } -}; diff --git a/Kernel/FileSystem/InodeIdentifier.h b/Kernel/FileSystem/InodeIdentifier.h index c05b92e8ac8..080d2f27464 100644 --- a/Kernel/FileSystem/InodeIdentifier.h +++ b/Kernel/FileSystem/InodeIdentifier.h @@ -61,11 +61,3 @@ struct AK::Formatter : AK::Formatter { return AK::Formatter::format(builder, "{}:{}", value.fsid(), value.index()); } }; - -template<> -struct AK::Formatter : AK::Formatter { - void format(FormatBuilder& builder, Kernel::InodeIndex value) - { - return AK::Formatter::format(builder, "{}", value.value()); - } -};