From eeb6f0337e21940240bf586420b55845d122896a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 13 May 2024 15:48:00 -0700 Subject: [PATCH] QByteArray: de-duplicate the find-one-char function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have a public, inlineable one, so use that one instead of the private copy. They do the same thing. Task-number: QTBUG-125283 Change-Id: If05cb740b64f42eba21efffd17cf2ded689e0691 Reviewed-by: Øystein Heskestad Reviewed-by: Ahmad Samir --- src/corelib/text/qbytearraymatcher.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/corelib/text/qbytearraymatcher.cpp b/src/corelib/text/qbytearraymatcher.cpp index ae38fb584b..411766c46e 100644 --- a/src/corelib/text/qbytearraymatcher.cpp +++ b/src/corelib/text/qbytearraymatcher.cpp @@ -212,23 +212,6 @@ qsizetype QByteArrayMatcher::indexIn(QByteArrayView data, qsizetype from) const \sa setPattern() */ - -static qsizetype findChar(const char *str, qsizetype len, char ch, qsizetype from) -{ - const uchar *s = (const uchar *)str; - uchar c = (uchar)ch; - if (from < 0) - from = qMax(from + len, qsizetype(0)); - if (from < len) { - const uchar *n = s + from - 1; - const uchar *e = s + len; - while (++n != e) - if (*n == c) - return n - s; - } - return -1; -} - /*! \internal */ @@ -268,7 +251,7 @@ qsizetype qFindByteArray( return -1; if (sl == 1) - return findChar(haystack0, haystackLen, needle[0], from); + return QtPrivate::findByteArray({ haystack0, haystackLen }, from, needle[0]); /* We use the Boyer-Moore algorithm in cases where the overhead