mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-26 20:30:06 +01:00
Use buffering in to_string to avoid bloat
This commit is contained in:
@@ -1444,9 +1444,8 @@ template <> struct formatter<detail::bigint> {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const detail::bigint& n, FormatContext& ctx) const ->
|
||||
typename FormatContext::iterator {
|
||||
auto format(const detail::bigint& n, format_context& ctx) const
|
||||
-> format_context::iterator {
|
||||
auto out = ctx.out();
|
||||
bool first = true;
|
||||
for (auto i = n.bigits_.size(); i > 0; --i) {
|
||||
|
||||
@@ -3426,8 +3426,8 @@ template <typename Char, typename OutputIt, typename T,
|
||||
FMT_CONSTEXPR auto write(OutputIt out, const T& value) -> enable_if_t<
|
||||
std::is_class<T>::value && !is_string<T>::value &&
|
||||
!is_floating_point<T>::value && !std::is_same<T, Char>::value &&
|
||||
!std::is_same<const T&,
|
||||
decltype(arg_mapper<Context>().map(value))>::value,
|
||||
!std::is_same<T, remove_cvref_t<decltype(arg_mapper<Context>().map(
|
||||
value))>>::value,
|
||||
OutputIt> {
|
||||
return write<Char>(out, arg_mapper<Context>().map(value));
|
||||
}
|
||||
@@ -4106,9 +4106,9 @@ auto join(Range&& range, string_view sep)
|
||||
*/
|
||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
|
||||
inline auto to_string(const T& value) -> std::string {
|
||||
auto result = std::string();
|
||||
detail::write<char>(std::back_inserter(result), value);
|
||||
return result;
|
||||
auto buffer = memory_buffer();
|
||||
detail::write<char>(appender(buffer), value);
|
||||
return {buffer.data(), buffer.size()};
|
||||
}
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
||||
|
||||
Reference in New Issue
Block a user