QByteArray: delegate to replace(char,char) from replace(QBAV,QBAV)

Don't go and build (among other things) a Boyer-Moore table for the
trivially optimizable replacement of single characters with single
characters. Just call the existing replace(char, char) overload.

Pick-to: 6.8
Change-Id: Ic69527bdaa5ce95bf937295366b94366e2ace933
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 60af93847e365fc00ccc4bcf61bb90ef6da1f0b2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2025-02-13 14:45:18 +01:00 committed by Qt Cherry-pick Bot
parent 6cefb8be96
commit 72f41f8756

View File

@ -2508,6 +2508,9 @@ QByteArray &QByteArray::replace(QByteArrayView before, QByteArrayView after)
const char *a = after.data();
qsizetype asize = after.size();
if (bsize == 1 && asize == 1)
return replace(*b, *a); // use the fast char-char algorithm
if (isNull() || (b == a && bsize == asize))
return *this;