From 1ca3af0a71f1df4f3fe5940b177bb8afac1e208d Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Thu, 10 Sep 2020 14:11:27 +0200 Subject: [PATCH] QString: use QCommonArrayOps::erase instead of custom logic With 6e8985e3576a4439bd66c0767f9912d1e124682c merged we can now use generic erase logic provided by array operations. This commit aligns QString with QList/QByteArray Task-number: QTBUG-84320 Change-Id: I83e9349e2461afd98737df25613aa2d0fd817a71 Reviewed-by: Thiago Macieira --- src/corelib/text/qstring.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index f34a1007474..18ac05a41b6 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2974,10 +2974,8 @@ QString &QString::remove(qsizetype pos, qsizetype len) resize(pos); // truncate } else if (len > 0) { detach(); - memmove(d.data() + pos, d.data() + pos + len, - (d.size - pos - len) * sizeof(QChar)); - d.size -= len; - d.data()[d.size] = '\0'; + d->erase(d.begin() + pos, d.begin() + pos + len); + d.data()[d.size] = u'\0'; } return *this; }