From 695912c7cf1b3ce59401f73bd7b18a666a77cda6 Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 15 Feb 2020 12:06:01 +0200 Subject: [PATCH] Optimize ansicolor_sink to use array instead of map to find color codes --- include/spdlog/common.h | 1 + include/spdlog/sinks/ansicolor_sink.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 830220ef..e1108a0a 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -147,6 +147,7 @@ enum level_enum err = SPDLOG_LEVEL_ERROR, critical = SPDLOG_LEVEL_CRITICAL, off = SPDLOG_LEVEL_OFF, + n_levels }; #if !defined(SPDLOG_LEVEL_NAMES) diff --git a/include/spdlog/sinks/ansicolor_sink.h b/include/spdlog/sinks/ansicolor_sink.h index 16433019..f81c40ac 100644 --- a/include/spdlog/sinks/ansicolor_sink.h +++ b/include/spdlog/sinks/ansicolor_sink.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace spdlog { namespace sinks { @@ -80,7 +80,7 @@ private: mutex_t &mutex_; bool should_do_colors_; std::unique_ptr formatter_; - std::unordered_map colors_; + std::array colors_; void print_ccode_(const string_view_t &color_code); void print_range_(const memory_buf_t &formatted, size_t start, size_t end); };