summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobal.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-02-25 17:41:11 -0800
committerThiago Macieira <thiago.macieira@intel.com>2018-03-18 17:28:42 +0000
commitdaa7f5375c58464bbe92744599f1e2258445e259 (patch)
tree289bb1a2c7de12768752cceed296780c63fcf995 /src/corelib/global/qglobal.h
parent9b68dc19bf3973d3a46439c4b8667ad3beba167d (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/global/qglobal.h')
-rw-r--r--src/corelib/global/qglobal.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 33885021ba..e31d4d9ad7 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -747,12 +747,13 @@ Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() Q_DECL_NOTHROW;
# define QT_DEBUG
#endif
+// QtPrivate::asString defined in qstring.h
#ifndef qPrintable
-# define qPrintable(string) QString(string).toLocal8Bit().constData()
+# define qPrintable(string) QtPrivate::asString(string).toLocal8Bit().constData()
#endif
#ifndef qUtf8Printable
-# define qUtf8Printable(string) QString(string).toUtf8().constData()
+# define qUtf8Printable(string) QtPrivate::asString(string).toUtf8().constData()
#endif
/*