From c24572d2a494dc2f8e16aad8857e1b7a8e6a7a09 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Wed, 4 Oct 2023 18:28:23 +0300 Subject: [PATCH] QString: proper compare of iterators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Canonical way is compare result of std::find_if against end by != operator, not < Change-Id: Ifffbaf11416ea0738a1ccbb2f2f8482193390070 Reviewed-by: MÃ¥rten Nordheim --- src/corelib/text/qstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index ca81384af80..cb32b4a31f5 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -9780,7 +9780,7 @@ qsizetype QtPrivate::findString(QLatin1StringView haystack, qsizetype from, QLat const auto end = haystack.end() - needle.size() + 1; auto ciMatch = CaseInsensitiveL1::matcher(needle[0].toLatin1()); const qsizetype nlen1 = needle.size() - 1; - for (auto it = std::find_if(begin + from, end, ciMatch); it < end; + for (auto it = std::find_if(begin + from, end, ciMatch); it != end; it = std::find_if(it + 1, end, ciMatch)) { // In this comparison we skip the first character because we know it's a match if (!nlen1 || QLatin1StringView(it + 1, nlen1).compare(needle.sliced(1), cs) == 0)