From 25aac40a4f3a34214cf195a80bc5c500c1658592 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 18 Jun 2022 21:16:37 +0200 Subject: [PATCH] Small fix --- src/common/utils/string.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/common/utils/string.cpp b/src/common/utils/string.cpp index 735c56ac..6d68378a 100644 --- a/src/common/utils/string.cpp +++ b/src/common/utils/string.cpp @@ -207,21 +207,23 @@ namespace utils::string bool strstr_lower(const char* a, const char* b) { - size_t index{}; - while (*a != '\0' && b[index] != '\0') + const char* a_ = a; + const char* b_ = b; + + while (*a_ != '\0' && *b_ != '\0') { - if (std::tolower(*a) == std::tolower(b[index])) + if (std::tolower(*a_) == std::tolower(*b_)) { - index++; + b_++; } - else if (index != 0) + else { - return false; + b_ = b; } - a++; + a_++; } - return b[index] == '\0'; + return *b_ == '\0'; } }