diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-10-11 15:01:06 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-12-08 23:48:12 +0000 |
commit | 6de49f4ab6e6c8c6e664f7dd6c8c441bf7685a56 (patch) | |
tree | 27ea49daa4e7cf5edeb7b0f0660b6d3bc410b52b /src/corelib/tools/qstring.h | |
parent | 2baeeb4026e55955a329480b2550a4353291f8ca (diff) |
QString: where possible, re-use existing capacity in op(QChar/QL1S)
If the LHS is detached and has existing capacity that is large
enough to hold the RHS, re-use the memory instead of allocating
a new buffer and throwing away the old.
Change-Id: I53d42825da92c264c7301e8e771cba9fb35c321b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qstring.h')
-rw-r--r-- | src/corelib/tools/qstring.h | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index d21708efb9..1d04bcb457 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -221,7 +221,7 @@ public: inline ~QString(); QString &operator=(QChar c); QString &operator=(const QString &) Q_DECL_NOTHROW; - inline QString &operator=(QLatin1String latin1); + QString &operator=(QLatin1String latin1); #ifdef Q_COMPILER_RVALUE_REFS inline QString(QString && other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); } inline QString &operator=(QString &&other) Q_DECL_NOTHROW @@ -884,11 +884,6 @@ inline void QString::detach() { if (d->ref.isShared() || (d->offset != sizeof(QStringData))) reallocData(uint(d->size) + 1u); } inline bool QString::isDetached() const { return !d->ref.isShared(); } -inline QString &QString::operator=(QLatin1String s) -{ - *this = fromLatin1(s.latin1(), s.size()); - return *this; -} inline void QString::clear() { if (!isNull()) *this = QString(); } inline QString::QString(const QString &other) Q_DECL_NOTHROW : d(other.d) |