Commit 695912c7 authored by gabime's avatar gabime

Optimize ansicolor_sink to use array instead of map to find color codes

parent 5c06306c
......@@ -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)
......
......@@ -9,7 +9,7 @@
#include <memory>
#include <mutex>
#include <string>
#include <unordered_map>
#include <array>
namespace spdlog {
namespace sinks {
......@@ -80,7 +80,7 @@ private:
mutex_t &mutex_;
bool should_do_colors_;
std::unique_ptr<spdlog::formatter> formatter_;
std::unordered_map<level::level_enum, string_view_t, level::level_hasher> colors_;
std::array<string_view_t , level::n_levels> colors_;
void print_ccode_(const string_view_t &color_code);
void print_range_(const memory_buf_t &formatted, size_t start, size_t end);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment