summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/text/qstring.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index fc1a9f2a83..631b279332 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -2883,7 +2883,15 @@ static void removeStringImpl(QString &s, const T &needle, Qt::CaseSensitivity cs
*/
QString &QString::remove(const QString &str, Qt::CaseSensitivity cs)
{
- removeStringImpl(*this, str, cs);
+ const auto s = reinterpret_cast<const ushort *>(str.data());
+ const std::less<const ushort *> less;
+ if (!less(s, d.data()) && less(s, d.data() + d.size)) {
+ // Part of me - take a copy
+ const QVarLengthArray<ushort> copy(s, s + str.size());
+ removeStringImpl(*this, QStringView{copy.data(), copy.size()}, cs);
+ } else {
+ removeStringImpl(*this, qToStringViewIgnoringNull(str), cs);
+ }
return *this;
}