From d299603e45d16308cbd452a4a6acbc1c0a8b9e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ka=C4=9Fan=20Can=20=C5=9Eit?= Date: Sat, 10 Jan 2026 21:07:34 +0300 Subject: [PATCH] Add missing const qualifiers to reference variables (#3514) --- include/spdlog/details/registry-inl.h | 2 +- include/spdlog/pattern_formatter-inl.h | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/spdlog/details/registry-inl.h b/include/spdlog/details/registry-inl.h index 576eebe0..c1af924d 100644 --- a/include/spdlog/details/registry-inl.h +++ b/include/spdlog/details/registry-inl.h @@ -257,7 +257,7 @@ SPDLOG_INLINE void registry::throw_if_exists_(const std::string &logger_name) { } SPDLOG_INLINE void registry::register_logger_(std::shared_ptr new_logger) { - auto &logger_name = new_logger->name(); + const auto &logger_name = new_logger->name(); throw_if_exists_(logger_name); loggers_[logger_name] = std::move(new_logger); } diff --git a/include/spdlog/pattern_formatter-inl.h b/include/spdlog/pattern_formatter-inl.h index 5204f58f..25aa505b 100644 --- a/include/spdlog/pattern_formatter-inl.h +++ b/include/spdlog/pattern_formatter-inl.h @@ -813,7 +813,7 @@ public: : flag_formatter(padinfo) {} void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override { - auto &mdc_map = mdc::get_context(); + const auto &mdc_map = mdc::get_context(); if (mdc_map.empty()) { ScopedPadder p(0, padinfo_, dest); return; @@ -823,11 +823,10 @@ public: } void format_mdc(const mdc::mdc_map_t &mdc_map, memory_buf_t &dest) { - auto last_element = --mdc_map.end(); + const auto last_element = std::prev(mdc_map.end()); for (auto it = mdc_map.begin(); it != mdc_map.end(); ++it) { - auto &pair = *it; - const auto &key = pair.first; - const auto &value = pair.second; + const auto &key = it->first; + const auto &value = it->second; size_t content_size = key.size() + value.size() + 1; // 1 for ':' if (it != last_element) {