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.9 6.8
Change-Id: Ic69527bdaa5ce95bf937295366b94366e2ace933
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
Marc Mutz 2025-02-13 14:45:18 +01:00
parent 4308ab70ca
commit 60af93847e

View File

@ -2533,6 +2533,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;