summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2020-10-30 19:34:22 +0100
committerLars Knoll <lars.knoll@qt.io>2020-11-04 11:22:20 +0100
commita7b6f0391b437e4b1a1d834421edfa78ff2ec14c (patch)
tree08bfec4589dfb6dae5fe125274c6d3acc40757ef
parent1282c05cdcc935a5eb1be150b8fd88f7771e81de (diff)
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>
-rw-r--r--src/corelib/text/qstring.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 1f32c4db7d..32e5bb7b20 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;