From 39e4a4bb903fe412b8aa82dc2e25a3929d807c5c Mon Sep 17 00:00:00 2001 From: modeco80 Date: Tue, 22 Aug 2023 16:57:11 -0400 Subject: [PATCH] lets see if this makes thing less slow on windows --- src/fprint.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/fprint.hpp b/src/fprint.hpp index 1a24b66..22e5bc0 100644 --- a/src/fprint.hpp +++ b/src/fprint.hpp @@ -5,6 +5,11 @@ #include #include +#ifdef _WIN32 +#define _WIN32_LEAN_AND_MEAN +#include +#endif + namespace swbf { struct FputcIterator { using iterator_category = std::output_iterator_tag; @@ -30,6 +35,11 @@ namespace swbf { /// Poor Man's C++23 template inline void fprint(std::FILE* file, std::string_view format, Args&&... args) { +#ifdef _WIN32 + auto str = std::vformat(format, std::make_format_args(args...)); + WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), str.data(), str.length(), nullptr, nullptr); +#else std::vformat_to(FputcIterator(file), format, std::make_format_args(args...)); +#endif } } // namespace swbf