QByteArrayView: move up the call to 1-char findByteArray()

The public, inline QtPrivate::findByteArray() function duplicates some
of the entry conditions that this does (including the negative from), so
help the compilers.

Task-number: QTBUG-125283
Change-Id: If05cb740b64f42eba21efffd17cf3034ce9ab9b8
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
bb10
Thiago Macieira 2024-05-13 16:29:46 -07:00
parent 7200f8638c
commit 726379c581
1 changed files with 3 additions and 3 deletions

View File

@ -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