Always use fast path in QString::append(QLatin1String)

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 <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Andrei Golubev 2020-10-30 19:34:22 +01:00 committed by Lars Knoll
parent 1282c05cdc
commit a7b6f0391b

View File

@ -2835,13 +2835,10 @@ QString &QString::append(QLatin1String str)
if (d->needsDetach() || str.size() > d->freeSpaceAtEnd()) if (d->needsDetach() || str.size() > d->freeSpaceAtEnd())
reallocGrowData(len); reallocGrowData(len);
if (d.freeSpaceAtBegin() == 0) { // fast path Q_ASSERT(str.size() <= d->freeSpaceAtEnd());
char16_t *i = d.data() + d.size; char16_t *i = d.data() + d.size;
qt_from_latin1(i, s, size_t(len)); qt_from_latin1(i, s, size_t(len));
d.size += len; d.size += len;
} else { // slow path
d->copyAppend(s, s + len);
}
d.data()[d.size] = '\0'; d.data()[d.size] = '\0';
} }
return *this; return *this;