From 04250a86059dd6931b9a8e7d60bd47b30fc12019 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Wed, 3 Aug 2022 16:05:01 +0200 Subject: [PATCH] Util: Add default alignment to string types --- src/util/format/builder.cpp | 1 + src/util/format/format.cpp | 2 +- src/util/format/formatter.cpp | 5 ----- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/util/format/builder.cpp b/src/util/format/builder.cpp index 8ff3af6..1bab4ca 100644 --- a/src/util/format/builder.cpp +++ b/src/util/format/builder.cpp @@ -63,6 +63,7 @@ void Builder::putString(std::string_view string, size_t width, Align align, char } switch (align) { + case Align::None: case Align::Left: m_builder.write(string.data(), length); m_builder << std::string(width - length, fill); diff --git a/src/util/format/format.cpp b/src/util/format/format.cpp index 965d2e5..f2936f6 100644 --- a/src/util/format/format.cpp +++ b/src/util/format/format.cpp @@ -31,7 +31,7 @@ void variadicFormatImpl(Builder& builder, Parser& parser, TypeErasedParameters& // Get parameter at index, or next size_t index = indexMaybe.has_value() ? indexMaybe.value() : parameters.tell(); - VERIFY(index < parameters.size(), "argument not found at index '%zu':'%zu'", index, parameters.size()); + VERIFY(index < parameters.size(), "argument not found at index '%zu'", index); auto& parameter = parameters.parameter(index); // Format the parameter diff --git a/src/util/format/formatter.cpp b/src/util/format/formatter.cpp index 8536f0f..166c74e 100644 --- a/src/util/format/formatter.cpp +++ b/src/util/format/formatter.cpp @@ -85,11 +85,6 @@ void Formatter::format(Builder& builder, bool value) const template<> void Formatter::format(Builder& builder, std::string_view value) const { - if (specifier.align == Builder::Align::None) { - builder.putString(value, specifier.width); - return; - } - builder.putString(value, specifier.width, specifier.align, specifier.fill); }