From 8f6d123586629e29f61418edd1bda8736c72bdeb Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 27 May 2021 21:58:50 -0700 Subject: [PATCH] remove std::distance usage std::distance internally runs a loop, which may or may not be optimized away. Just use simple arithmetic. Signed-off-by: Rosen Penev --- include/spdlog/common-inl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/spdlog/common-inl.h b/include/spdlog/common-inl.h index f8347656..97cbbddc 100644 --- a/include/spdlog/common-inl.h +++ b/include/spdlog/common-inl.h @@ -34,7 +34,7 @@ SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG { auto it = std::find(std::begin(level_string_views), std::end(level_string_views), name); if (it != std::end(level_string_views)) - return static_cast(std::distance(std::begin(level_string_views), it)); + return static_cast(it - std::begin(level_string_views)); // check also for "warn" and "err" before giving up.. if (name == "warn")