Optimize default formatting

This commit is contained in:
Victor Zverovich
2018-09-12 07:34:22 -07:00
parent c8a8464f7d
commit 7110b46076
5 changed files with 58 additions and 44 deletions

View File

@@ -19,14 +19,15 @@ class custom_arg_formatter :
typedef fmt::back_insert_range<fmt::internal::buffer> range;
typedef fmt::arg_formatter<range> base;
custom_arg_formatter(fmt::format_context &ctx, fmt::format_specs &s)
custom_arg_formatter(
fmt::format_context &ctx, fmt::format_specs *s = FMT_NULL)
: base(ctx, s) {}
using base::operator();
iterator operator()(double value) {
// Comparing a float to 0.0 is safe
if (round(value * pow(10, spec().precision())) == 0.0)
if (round(value * pow(10, spec()->precision())) == 0.0)
value = 0;
return base::operator()(value);
}