mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-24 17:41:34 +08:00
Optimize ansicolor_sink to use array instead of map to find color codes
This commit is contained in:
parent
5c06306ccc
commit
695912c7cf
@ -147,6 +147,7 @@ enum level_enum
|
|||||||
err = SPDLOG_LEVEL_ERROR,
|
err = SPDLOG_LEVEL_ERROR,
|
||||||
critical = SPDLOG_LEVEL_CRITICAL,
|
critical = SPDLOG_LEVEL_CRITICAL,
|
||||||
off = SPDLOG_LEVEL_OFF,
|
off = SPDLOG_LEVEL_OFF,
|
||||||
|
n_levels
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(SPDLOG_LEVEL_NAMES)
|
#if !defined(SPDLOG_LEVEL_NAMES)
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <array>
|
||||||
|
|
||||||
namespace spdlog {
|
namespace spdlog {
|
||||||
namespace sinks {
|
namespace sinks {
|
||||||
@ -80,7 +80,7 @@ private:
|
|||||||
mutex_t &mutex_;
|
mutex_t &mutex_;
|
||||||
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, 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_ccode_(const string_view_t &color_code);
|
||||||
void print_range_(const memory_buf_t &formatted, size_t start, size_t end);
|
void print_range_(const memory_buf_t &formatted, size_t start, size_t end);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user