mirror of
https://github.com/fmtlib/fmt.git
synced 2024-10-02 04:52:03 +00:00
Minor cleanup
This commit is contained in:
parent
993f56cff6
commit
3135421257
@ -926,9 +926,8 @@ template <typename T> class buffer {
|
|||||||
|
|
||||||
/// Appends data to the end of the buffer.
|
/// Appends data to the end of the buffer.
|
||||||
template <typename U>
|
template <typename U>
|
||||||
// Workaround for Visual Studio 2019 to fix error C2893: Failed to specialize
|
// Workaround for MSVC2019 to fix error C2893: Failed to specialize function
|
||||||
// function template 'void fmt::v11::detail::buffer<T>::append(const U *,const
|
// template 'void fmt::v11::detail::buffer<T>::append(const U *,const U *)'.
|
||||||
// U *)'
|
|
||||||
#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1930
|
#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1930
|
||||||
FMT_CONSTEXPR20
|
FMT_CONSTEXPR20
|
||||||
#endif
|
#endif
|
||||||
@ -2285,7 +2284,7 @@ template <typename Char>
|
|||||||
FMT_CONSTEXPR auto code_point_length(const Char* begin) -> int {
|
FMT_CONSTEXPR auto code_point_length(const Char* begin) -> int {
|
||||||
if (const_check(sizeof(Char) != 1)) return 1;
|
if (const_check(sizeof(Char) != 1)) return 1;
|
||||||
auto c = static_cast<unsigned char>(*begin);
|
auto c = static_cast<unsigned char>(*begin);
|
||||||
return static_cast<int>((0x3a55000000000000ull >> (2 * (c >> 3))) & 0x3) + 1;
|
return static_cast<int>((0x3a55000000000000ull >> (2 * (c >> 3))) & 3) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the result via the out param to workaround gcc bug 77539.
|
// Return the result via the out param to workaround gcc bug 77539.
|
||||||
@ -2880,8 +2879,7 @@ inline void report_truncation(bool truncated) {
|
|||||||
if (truncated) report_error("output is truncated");
|
if (truncated) report_error("output is truncated");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use vformat_args and avoid type_identity to keep symbols short and workaround
|
// Use vformat_args and avoid type_identity to keep symbols short.
|
||||||
// a GCC <= 4.8 bug.
|
|
||||||
template <typename Char = char> struct vformat_args {
|
template <typename Char = char> struct vformat_args {
|
||||||
using type = basic_format_args<buffered_context<Char>>;
|
using type = basic_format_args<buffered_context<Char>>;
|
||||||
};
|
};
|
||||||
|
@ -2264,25 +2264,23 @@ FMT_CONSTEXPR auto write(OutputIt out, basic_string_view<Char> s,
|
|||||||
auto size = s.size();
|
auto size = s.size();
|
||||||
if (specs.precision >= 0 && to_unsigned(specs.precision) < size)
|
if (specs.precision >= 0 && to_unsigned(specs.precision) < size)
|
||||||
size = code_point_index(s, to_unsigned(specs.precision));
|
size = code_point_index(s, to_unsigned(specs.precision));
|
||||||
bool is_debug = specs.type() == presentation_type::debug;
|
|
||||||
size_t width = 0;
|
|
||||||
|
|
||||||
|
bool is_debug = specs.type() == presentation_type::debug;
|
||||||
if (is_debug) {
|
if (is_debug) {
|
||||||
auto buf = counting_buffer<Char>();
|
auto buf = counting_buffer<Char>();
|
||||||
write_escaped_string(basic_appender<Char>(buf), s);
|
write_escaped_string(basic_appender<Char>(buf), s);
|
||||||
size = buf.count();
|
size = buf.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t width = 0;
|
||||||
if (specs.width != 0) {
|
if (specs.width != 0) {
|
||||||
if (is_debug)
|
width =
|
||||||
width = size;
|
is_debug ? size : compute_width(basic_string_view<Char>(data, size));
|
||||||
else
|
|
||||||
width = compute_width(basic_string_view<Char>(data, size));
|
|
||||||
}
|
}
|
||||||
return write_padded<Char>(out, specs, size, width,
|
return write_padded<Char>(
|
||||||
[=](reserve_iterator<OutputIt> it) {
|
out, specs, size, width, [=](reserve_iterator<OutputIt> it) {
|
||||||
if (is_debug) return write_escaped_string(it, s);
|
return is_debug ? write_escaped_string(it, s)
|
||||||
return copy<Char>(data, data + size, it);
|
: copy<Char>(data, data + size, it);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
template <typename Char, typename OutputIt>
|
template <typename Char, typename OutputIt>
|
||||||
|
Loading…
Reference in New Issue
Block a user