mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
Added small_map_threshold constexpr
This commit is contained in:
parent
b95e493471
commit
e1f5a45900
@ -22,6 +22,8 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
static constexpr size_t small_map_threshold = 10;
|
||||
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
|
||||
@ -70,7 +72,7 @@ namespace spdlog {
|
||||
|
||||
// if the map is small do a sequential search, otherwise use the standard find()
|
||||
std::shared_ptr<logger> registry::get(const std::string &logger_name) {
|
||||
if (loggers_.size() <= 10) {
|
||||
if (loggers_.size() <= small_map_threshold) {
|
||||
for (const auto &[key, val]: loggers_) {
|
||||
if (logger_name == key) {
|
||||
return val;
|
||||
@ -89,7 +91,7 @@ namespace spdlog {
|
||||
std::shared_ptr<logger> registry::get(std::string_view logger_name) {
|
||||
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||
|
||||
if (loggers_.size() <= 10) {
|
||||
if (loggers_.size() <= small_map_threshold) {
|
||||
for (const auto &[key, val]: loggers_) {
|
||||
if (logger_name == key) {
|
||||
return val;
|
||||
|
Loading…
Reference in New Issue
Block a user