From b71d3fe7abcdd1b323cee28f72e4d57b277e3ca7 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 17 Oct 2018 17:01:22 -0700 Subject: [PATCH] Remove use_grisu --- include/fmt/format.h | 7 ++----- test/format-test.cc | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index a500c35b..914da868 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -163,6 +163,7 @@ FMT_END_NAMESPACE #ifndef FMT_USE_GRISU # define FMT_USE_GRISU 0 +//# define FMT_USE_GRISU std::numeric_limits::is_iec559 #endif // __builtin_clz is broken in clang with Microsoft CodeGen: @@ -1177,10 +1178,6 @@ FMT_CONSTEXPR unsigned basic_parse_context::next_arg_id() { namespace internal { -inline bool use_grisu() { - return FMT_USE_GRISU && std::numeric_limits::is_iec559; -} - // Formats value using Grisu2 algorithm: // https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf template @@ -2841,7 +2838,7 @@ void basic_writer::write_double(T value, const format_specs &spec) { return write_inf_or_nan(handler.upper ? "INF" : "inf"); memory_buffer buffer; - bool use_grisu = internal::use_grisu() && sizeof(T) <= sizeof(double) && + bool use_grisu = FMT_USE_GRISU && sizeof(T) <= sizeof(double) && spec.type != 'a' && spec.type != 'A' && internal::grisu2_format(static_cast(value), buffer, spec); if (!use_grisu) { diff --git a/test/format-test.cc b/test/format-test.cc index d528d49c..163dd22e 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -996,7 +996,7 @@ TEST(FormatterTest, HashFlag) { EXPECT_EQ("0x42", format("{0:#x}", 0x42ull)); EXPECT_EQ("042", format("{0:#o}", 042ull)); - if (fmt::internal::use_grisu()) + if (FMT_USE_GRISU) EXPECT_EQ("-42.0", format("{0:#}", -42.0)); else EXPECT_EQ("-42.0000", format("{0:#}", -42.0));