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 <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2021-05-27 21:58:50 -07:00
parent d368ed586c
commit 8f6d123586

View File

@ -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); auto it = std::find(std::begin(level_string_views), std::end(level_string_views), name);
if (it != std::end(level_string_views)) if (it != std::end(level_string_views))
return static_cast<level::level_enum>(std::distance(std::begin(level_string_views), it)); return static_cast<level::level_enum>(it - std::begin(level_string_views));
// check also for "warn" and "err" before giving up.. // check also for "warn" and "err" before giving up..
if (name == "warn") if (name == "warn")