From 780fc531fd3a41bef0d8544f2f79c2faec994deb Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Mon, 8 Apr 2024 21:30:04 -0700 Subject: [PATCH] Update GeneralUtils.h --- dCommon/GeneralUtils.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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);