From 0f4133aacfa2ebc84c76f69e6ab02ce58603072f Mon Sep 17 00:00:00 2001 From: Greg Falcon Date: Fri, 9 Jun 2023 09:38:13 -0700 Subject: StrFormat() simplification: Treat %v unconditionally as %d when formatting integers. This is a simplification but not a behavior change; we used to choose %u for unsigned ints, but %u and %d generate the same output for these types. PiperOrigin-RevId: 539104599 Change-Id: I9d7ff561b969a6287889f95063636d6b77a4a78b --- absl/strings/internal/str_format/arg.cc | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/absl/strings/internal/str_format/arg.cc b/absl/strings/internal/str_format/arg.cc index 018dd052..6033a75a 100644 --- a/absl/strings/internal/str_format/arg.cc +++ b/absl/strings/internal/str_format/arg.cc @@ -278,24 +278,6 @@ bool ConvertIntImplInnerSlow(const IntDigits &as_digits, return true; } -template ::value && - std::is_signed::value) || - std::is_same::value, - int>::type = 0> -constexpr auto ConvertV(T) { - return FormatConversionCharInternal::d; -} - -template ::value && - std::is_unsigned::value) || - std::is_same::value, - int>::type = 0> -constexpr auto ConvertV(T) { - return FormatConversionCharInternal::u; -} - template bool ConvertFloatArg(T v, FormatConversionSpecImpl conv, FormatSinkImpl *sink) { if (conv.conversion_char() == FormatConversionCharInternal::v) { @@ -332,10 +314,6 @@ bool ConvertIntArg(T v, FormatConversionSpecImpl conv, FormatSinkImpl *sink) { using U = typename MakeUnsigned::type; IntDigits as_digits; - if (conv.conversion_char() == FormatConversionCharInternal::v) { - conv.set_conversion_char(ConvertV(T{})); - } - // This odd casting is due to a bug in -Wswitch behavior in gcc49 which causes // it to complain about a switch/case type mismatch, even though both are // FormatConverionChar. Likely this is because at this point @@ -361,6 +339,7 @@ bool ConvertIntArg(T v, FormatConversionSpecImpl conv, FormatSinkImpl *sink) { case static_cast(FormatConversionCharInternal::d): case static_cast(FormatConversionCharInternal::i): + case static_cast(FormatConversionCharInternal::v): as_digits.PrintAsDec(v); break; -- cgit v1.2.3