diff --git a/src/corelib/text/qbytearraymatcher.cpp b/src/corelib/text/qbytearraymatcher.cpp index b3e38d53e4..67cf355ddf 100644 --- a/src/corelib/text/qbytearraymatcher.cpp +++ b/src/corelib/text/qbytearraymatcher.cpp @@ -243,6 +243,9 @@ qsizetype QtPrivate::findByteArray(QByteArrayView haystack, qsizetype from, QByt const auto haystack0 = haystack.data(); const auto l = haystack.size(); const auto sl = needle.size(); + if (sl == 1) + return findByteArray(haystack, from, needle.front()); + if (from < 0) from += l; if (std::size_t(sl + from) > std::size_t(l)) @@ -252,9 +255,6 @@ qsizetype QtPrivate::findByteArray(QByteArrayView haystack, qsizetype from, QByt if (!l) return -1; - if (sl == 1) - return findByteArray(haystack, from, needle.front()); - /* We use the Boyer-Moore algorithm in cases where the overhead for the skip table should pay off, otherwise we use a simple