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>
This commit is contained in:
parent
aca0e367be
commit
5d935dca0c
@ -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));
|
||||
|
@ -803,7 +803,9 @@ private:
|
||||
Data *d;
|
||||
|
||||
void reallocData(uint alloc, bool grow = false);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
void expand(int i);
|
||||
#endif
|
||||
QString multiArg(int numArgs, const QString **args) const;
|
||||
static int compare_helper(const QChar *data1, int length1,
|
||||
const QChar *data2, int length2,
|
||||
@ -990,7 +992,7 @@ public:
|
||||
inline operator QChar() const
|
||||
{ return i < s.d->size ? s.d->data()[i] : 0; }
|
||||
inline QCharRef &operator=(QChar c)
|
||||
{ if (i >= s.d->size) s.expand(i); else s.detach();
|
||||
{ if (i >= s.d->size) s.resize(i + 1, QLatin1Char(' ')); else s.detach();
|
||||
s.d->data()[i] = c.unicode(); return *this; }
|
||||
|
||||
// An operator= for each QChar cast constructors
|
||||
|
Loading…
x
Reference in New Issue
Block a user