Skip to content

Commit

Permalink
Unbloat chrono
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jul 22, 2024
1 parent 42d3d70 commit eab07ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,7 @@ struct formatter<std::chrono::duration<Rep, Period>, Char> {
// As a possible future optimization, we could avoid extra copying if width
// is not specified.
auto buf = basic_memory_buffer<Char>();
auto out = std::back_inserter(buf);
auto out = basic_appender<Char>(buf);
detail::handle_dynamic_spec<detail::width_checker>(specs.width, width_ref_,
ctx);
detail::handle_dynamic_spec<detail::precision_checker>(precision,
Expand Down Expand Up @@ -2388,7 +2388,7 @@ template <typename Char> struct formatter<std::tm, Char> {
const Duration* subsecs) const -> decltype(ctx.out()) {
auto specs = specs_;
auto buf = basic_memory_buffer<Char>();
auto out = std::back_inserter(buf);
auto out = basic_appender<Char>(buf);
detail::handle_dynamic_spec<detail::width_checker>(specs.width, width_ref_,
ctx);

Expand Down
6 changes: 3 additions & 3 deletions include/fmt/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ auto format_to_n(OutputIt out, size_t n, const S& fmt, Args&&... args)

template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
FMT_CONSTEXPR20 auto formatted_size(const S& fmt, const Args&... args)
-> size_t {
return fmt::format_to(detail::counting_iterator(), fmt, args...).count();
auto formatted_size(const S& fmt, const Args&... args) -> size_t {
auto buf = detail::counting_buffer<>();
return fmt::format_to(fmt::appender(buf), fmt, args...).count();
}

template <typename S, typename... Args,
Expand Down
8 changes: 4 additions & 4 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1314,10 +1314,10 @@ FMT_CONSTEXPR20 auto format_decimal(Char* out, UInt value, int size)
return {begin + n, end};
}

template <typename Char, typename UInt, typename Iterator,
FMT_ENABLE_IF(!std::is_pointer<remove_cvref_t<Iterator>>::value)>
FMT_CONSTEXPR inline auto format_decimal(Iterator out, UInt value, int size)
-> format_decimal_result<Iterator> {
template <typename Char, typename UInt, typename OutputIt,
FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value)>
FMT_CONSTEXPR inline auto format_decimal(OutputIt out, UInt value, int size)
-> format_decimal_result<OutputIt> {
// Buffer is large enough to hold all digits (digits10 + 1).
Char buffer[digits10<UInt>() + 1] = {};
auto end = format_decimal(buffer, value, size).end;
Expand Down

0 comments on commit eab07ee

Please sign in to comment.