summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring_compat.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-07-28 19:50:35 -0700
committerThiago Macieira <thiago.macieira@intel.com>2014-11-02 20:51:57 +0100
commit294c914eb6bb5e0200480400ba31f2049edb9b86 (patch)
tree86fe3198ebc56f63efb2ea136be88e15a708368b /src/corelib/tools/qstring_compat.cpp
parent939197fd7c8b64256333d096f3b4ebbf066b2481 (diff)
Add rvalue-ref qualified {QString,QByteArray}::{simplified,trimmed}
Of the const overloads that return a QString or a QByteArray, this is one that gains the most benefit. It happens often in constructs like: QByteArray s = x.readLine().trimmed(); After this change, 41 out of 103 calls to trimmed become rvalue in Qt and 272 out of 441 in Qt Creator. For simplified, the numbers are 27 out of 69 in Qt and 10 out of 19 in Qt Creator. Other candidates are left, right, and mid, but there are exactly zero uses of left, right and mid on an xvalue QString or QByteArray in Qt. I'm being lazy and using qstring_compat.cpp to store the QByteArray compat methods. Change-Id: I4e410fc1adc4c761bb07cc3d43b348a65befa9f6 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools/qstring_compat.cpp')
-rw-r--r--src/corelib/tools/qstring_compat.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/corelib/tools/qstring_compat.cpp b/src/corelib/tools/qstring_compat.cpp
index bc48e3e5cf..d4f21e483a 100644
--- a/src/corelib/tools/qstring_compat.cpp
+++ b/src/corelib/tools/qstring_compat.cpp
@@ -42,6 +42,16 @@
QT_BEGIN_NAMESPACE
// all these implementations must be the same as the inline versions in qstring.h
+QString QString::trimmed() const
+{
+ return trimmed_helper(*this);
+}
+
+QString QString::simplified() const
+{
+ return simplified_helper(*this);
+}
+
QString QString::toLower() const
{
return toLower_helper(*this);
@@ -83,4 +93,14 @@ QByteArray QByteArray::toUpper() const
return toUpper_helper(*this);
}
+QByteArray QByteArray::trimmed() const
+{
+ return trimmed_helper(*this);
+}
+
+QByteArray QByteArray::simplified() const
+{
+ return simplified_helper(*this);
+}
+
QT_END_NAMESPACE