summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-07-12 12:44:01 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-07-14 06:54:16 +0000
commit5d935dca0c70618af519c5bef2e11b4a1ee03507 (patch)
treea4489321fe9ac7381ef5e2664f41f73a2f5438fd /src/corelib/tools/qstring.cpp
parentaca0e367be9cdc3b48f09200f4eadbcfe5a574c8 (diff)
Remove (private) QString::expand(), port to (new) QString::resize(int, QChar)
We cannot really remove the function, since it's called from inline code (QCharRef::op=(QChar)), but we can schedule it for removal in Qt 6, and inline it into existing in-tree callers. Change-Id: I3499f101dcb5ae908726b3673bf3526a04408db6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r--src/corelib/tools/qstring.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 9dc7136d2a..68d12d85af 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1789,17 +1789,12 @@ void QString::reallocData(uint alloc, bool grow)
}
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void QString::expand(int i)
{
- int sz = d->size;
- resize(qMax(i + 1, sz));
- if (d->size - 1 > sz) {
- ushort *n = d->data() + d->size - 1;
- ushort *e = d->data() + sz;
- while (n != e)
- * --n = ' ';
- }
+ resize(qMax(i + 1, d->size), QLatin1Char(' '));
}
+#endif
/*! \fn void QString::clear()
@@ -1986,7 +1981,7 @@ QString &QString::insert(int i, QLatin1String str)
int len = str.size();
if (Q_UNLIKELY(i > d->size))
- expand(i + len - 1);
+ resize(i + len, QLatin1Char(' '));
else
resize(d->size + len);
@@ -2019,7 +2014,7 @@ QString& QString::insert(int i, const QChar *unicode, int size)
}
if (Q_UNLIKELY(i > d->size))
- expand(i + size - 1);
+ resize(i + size, QLatin1Char(' '));
else
resize(d->size + size);
@@ -2042,7 +2037,7 @@ QString& QString::insert(int i, QChar ch)
if (i < 0)
return *this;
if (Q_UNLIKELY(i > d->size))
- expand(i);
+ resize(i + 1, QLatin1Char(' '));
else
resize(d->size + 1);
::memmove(d->data() + i + 1, d->data() + i, (d->size - i - 1) * sizeof(QChar));