Avoid overhead on sensible platforms

This commit is contained in:
Victor Zverovich 2022-04-11 16:52:34 -07:00
parent ce7ecdb7af
commit fc429d18b6

View File

@ -93,8 +93,9 @@ inline bool write(std::wfilebuf&, fmt::basic_string_view<wchar_t>) {
// It is a separate function rather than a part of vprint to simplify testing.
template <typename Char>
void write_buffer(std::basic_ostream<Char>& os, buffer<Char>& buf) {
if (auto filebuf = dynamic_cast<std::basic_filebuf<Char>*>(os.rdbuf())) {
if (write(*filebuf, {buf.data(), buf.size()})) return;
if (FMT_MSC_VER) {
auto filebuf = dynamic_cast<std::basic_filebuf<Char>*>(os.rdbuf());
if (filebuf && write(*filebuf, {buf.data(), buf.size()})) return;
}
const Char* buf_data = buf.data();
using unsigned_streamsize = std::make_unsigned<std::streamsize>::type;