optimize wincolor_sink to use array instead of map to find color codes

This commit is contained in:
gabime 2020-02-15 12:11:01 +02:00
parent 695912c7cf
commit 4b7c05903b

View File

@ -11,7 +11,7 @@
#include <memory> #include <memory>
#include <mutex> #include <mutex>
#include <string> #include <string>
#include <unordered_map> #include <array>
#include <wincon.h> #include <wincon.h>
namespace spdlog { namespace spdlog {
@ -52,7 +52,7 @@ protected:
bool in_console_; bool in_console_;
bool should_do_colors_; bool should_do_colors_;
std::unique_ptr<spdlog::formatter> formatter_; std::unique_ptr<spdlog::formatter> formatter_;
std::unordered_map<level::level_enum, WORD, level::level_hasher> colors_; std::array<WORD , level::n_levels> colors_;
// set foreground color and return the orig console attributes (for resetting later) // set foreground color and return the orig console attributes (for resetting later)
WORD set_foreground_color_(WORD attribs); WORD set_foreground_color_(WORD attribs);