From 37b847692e8bf460a75b560893968d394f2ebc24 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Tue, 30 Apr 2024 12:13:00 +0300 Subject: [PATCH] Revert pr #3023 (std::string_view overloads for logger accessor for c++17) --- include/spdlog/details/registry-inl.h | 24 ------------------------ include/spdlog/details/registry.h | 8 -------- include/spdlog/spdlog-inl.h | 9 --------- include/spdlog/spdlog.h | 8 -------- 4 files changed, 49 deletions(-) diff --git a/include/spdlog/details/registry-inl.h b/include/spdlog/details/registry-inl.h index d03934d9..4e99ba9d 100644 --- a/include/spdlog/details/registry-inl.h +++ b/include/spdlog/details/registry-inl.h @@ -84,30 +84,6 @@ SPDLOG_INLINE std::shared_ptr registry::get(const std::string &logger_na return found == loggers_.end() ? nullptr : found->second; } -#if __cplusplus >= 201703L // C++17 -// if the map is small do a sequential search and avoid creating string for find(logger_name) -// otherwise use the standard find() -SPDLOG_INLINE std::shared_ptr registry::get(std::string_view logger_name) { - std::lock_guard lock(logger_map_mutex_); - if (loggers_.size() <= 10) { - for (const auto &[key, val]: loggers_) { - if (logger_name == key) { - return val; - } - } - return nullptr; - } - // otherwise use the normal map lookup - else { - auto found = loggers_.find(std::string(logger_name)); - return found == loggers_.end() ? nullptr : found->second; - } -} - -SPDLOG_INLINE std::shared_ptr registry::get(const char *logger_name) { - return get(std::string_view(logger_name)); -} -#endif SPDLOG_INLINE std::shared_ptr registry::default_logger() { std::lock_guard lock(logger_map_mutex_); diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index d21f2b4d..412e3eaf 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -18,10 +18,6 @@ #include #include -#if __cplusplus >= 201703L // C++17 - #include -#endif - namespace spdlog { class logger; @@ -37,10 +33,6 @@ public: void register_logger(std::shared_ptr new_logger); void initialize_logger(std::shared_ptr new_logger); std::shared_ptr get(const std::string &logger_name); -#if __cplusplus >= 201703L // C++17 - std::shared_ptr get(std::string_view logger_name); - std::shared_ptr get(const char *logger_name); -#endif std::shared_ptr default_logger(); // Return raw ptr to the default logger. diff --git a/include/spdlog/spdlog-inl.h b/include/spdlog/spdlog-inl.h index 54cdc2cc..3e5d7458 100644 --- a/include/spdlog/spdlog-inl.h +++ b/include/spdlog/spdlog-inl.h @@ -20,15 +20,6 @@ SPDLOG_INLINE std::shared_ptr get(const std::string &name) { return details::registry::instance().get(name); } -#if __cplusplus >= 201703L // C++17 -SPDLOG_INLINE std::shared_ptr get(std::string_view name) { - return details::registry::instance().get(name); -} - -SPDLOG_INLINE std::shared_ptr get(const char *name) { - return details::registry::instance().get(name); -} -#endif SPDLOG_INLINE void set_formatter(std::unique_ptr formatter) { details::registry::instance().set_formatter(std::move(formatter)); diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index d2982633..a8afbcec 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -20,10 +20,6 @@ #include #include -#if __cplusplus >= 201703L // C++17 - #include -#endif - namespace spdlog { using default_factory = synchronous_factory; @@ -54,10 +50,6 @@ SPDLOG_API void initialize_logger(std::shared_ptr logger); // exist. // example: spdlog::get("my_logger")->info("hello {}", "world"); SPDLOG_API std::shared_ptr get(const std::string &name); -#if __cplusplus >= 201703L // C++17 -SPDLOG_API std::shared_ptr get(std::string_view name); -SPDLOG_API std::shared_ptr get(const char *name); -#endif // Set global formatter. Each sink in each logger will get a clone of this object SPDLOG_API void set_formatter(std::unique_ptr formatter);