diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-02-25 17:41:11 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-03-18 17:28:42 +0000 |
commit | daa7f5375c58464bbe92744599f1e2258445e259 (patch) | |
tree | 289bb1a2c7de12768752cceed296780c63fcf995 /src/corelib/tools/qstring.h | |
parent | 9b68dc19bf3973d3a46439c4b8667ad3beba167d (diff) |
q{,Utf8}Printable: avoid creating a copy of a QString
We have this QString() constructor call to permit things that convert to
QString but aren't QString to be used in qPrintable, like a
QStringBuilder-powered fast operator+ expression, like:
qPrintable(string1 + ": " + string2)
Unfortunately, it meant that we unnecessarily created a QString copy if
the input was already QString.
Change-Id: Iecab8770aa5840aba8edfffd1516bc94cec791a9
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qstring.h')
-rw-r--r-- | src/corelib/tools/qstring.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 0138ae4098..b8f4d49831 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1857,6 +1857,12 @@ QT_DEPRECATED inline QString escape(const QString &plain) { #endif } +namespace QtPrivate { +// used by qPrintable() and qUtf8Printable() macros +inline const QString &asString(const QString &s) { return s; } +inline QString &&asString(QString &&s) { return std::move(s); } +} + QT_END_NAMESPACE #if defined(QT_USE_FAST_OPERATOR_PLUS) || defined(QT_USE_QSTRINGBUILDER) |