From f091f371c486e04fed0b1083c163b1c2baaf028c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 21 Jan 2022 14:32:10 +0100 Subject: QByteArrayMatcher users: use the new QByteArrayView overloads The new overloads mean that when passing QByteArrayView or QLatin1String objects, we don't expand them into .data() and .size() anymore. Pick-to: 6.3 Change-Id: I0c898e0463d0bf81ce1f7d57e10e64f23bd84587 Reviewed-by: Sona Kurazyan --- src/corelib/text/qbytearray.cpp | 4 ++-- src/corelib/text/qstring.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 1966f24149..0329a26db8 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -2625,8 +2625,8 @@ qsizetype QtPrivate::count(QByteArrayView haystack, QByteArrayView needle) noexc qsizetype num = 0; qsizetype i = -1; if (haystack.size() > 500 && needle.size() > 5) { - QByteArrayMatcher matcher(needle.data(), needle.size()); - while ((i = matcher.indexIn(haystack.data(), haystack.size(), i + 1)) != -1) + QByteArrayMatcher matcher(needle); + while ((i = matcher.indexIn(haystack, i + 1)) != -1) ++num; } else { while ((i = haystack.indexOf(needle, i + 1)) != -1) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 80b9653ec9..7a908cfd98 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -10526,8 +10526,8 @@ qsizetype QtPrivate::findString(QLatin1String haystack, qsizetype from, QLatin1S return from; if (cs == Qt::CaseSensitive) { - const QByteArrayMatcher matcher(needle.data(), needle.size()); - return matcher.indexIn(haystack.data(), haystack.size(), from); + const QByteArrayMatcher matcher(needle); + return matcher.indexIn(haystack, from); } // If the needle is sufficiently small we simply iteratively search through -- cgit v1.2.3