From a7b6f0391b437e4b1a1d834421edfa78ff2ec14c Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Fri, 30 Oct 2020 19:34:22 +0100 Subject: [PATCH] Always use fast path in QString::append(QLatin1String) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This must be possible with a new set of changes and the way QString reallocates Task-number: QTBUG-86583 Change-Id: I513f51d7c6e984ae4e81fc344138687c791037c4 Reviewed-by: Qt CI Bot Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/corelib/text/qstring.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 1f32c4db7db..32e5bb7b20b 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2835,13 +2835,10 @@ QString &QString::append(QLatin1String str) if (d->needsDetach() || str.size() > d->freeSpaceAtEnd()) reallocGrowData(len); - if (d.freeSpaceAtBegin() == 0) { // fast path - char16_t *i = d.data() + d.size; - qt_from_latin1(i, s, size_t(len)); - d.size += len; - } else { // slow path - d->copyAppend(s, s + len); - } + Q_ASSERT(str.size() <= d->freeSpaceAtEnd()); + char16_t *i = d.data() + d.size; + qt_from_latin1(i, s, size_t(len)); + d.size += len; d.data()[d.size] = '\0'; } return *this;