diff --git a/dCommon/GeneralUtils.h b/dCommon/GeneralUtils.h index f59ec71f6..35c0b8957 100644 --- a/dCommon/GeneralUtils.h +++ b/dCommon/GeneralUtils.h @@ -158,9 +158,7 @@ namespace GeneralUtils { template [[nodiscard]] std::optional TryParse(std::string_view str) { numeric_parse_t result; - if (!str.empty()) { - while (std::isspace(str.front())) str.remove_prefix(1); - } + while (!str.empty() && std::isspace(str.front())) str.remove_prefix(1); const char* const strEnd = str.data() + str.size(); const auto [parseEnd, ec] = std::from_chars(str.data(), strEnd, result); @@ -186,9 +184,7 @@ namespace GeneralUtils { template [[nodiscard]] std::optional TryParse(std::string_view str) noexcept try { - if (!str.empty()) { - while (std::isspace(str.front())) str.remove_prefix(1); - } + while (!str.empty() && std::isspace(str.front())) str.remove_prefix(1); size_t parseNum; const T result = details::_parse(str, parseNum);