summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearray.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/qbytearray.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/qbytearray.cpp')
-rw-r--r--src/corelib/tools/qbytearray.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index f57bcdb424..625b78d001 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -3196,6 +3196,8 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba)
*/
/*!
+ \fn QByteArray QByteArray::simplified() const
+
Returns a byte array that has whitespace removed from the start
and the end, and which has each sequence of internal whitespace
replaced with a single space.
@@ -3209,12 +3211,19 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba)
\sa trimmed()
*/
-QByteArray QByteArray::simplified() const
+QByteArray QByteArray::simplified_helper(const QByteArray &a)
{
- return QStringAlgorithms<const QByteArray>::simplified_helper(*this);
+ return QStringAlgorithms<const QByteArray>::simplified_helper(a);
+}
+
+QByteArray QByteArray::simplified_helper(QByteArray &a)
+{
+ return QStringAlgorithms<QByteArray>::simplified_helper(a);
}
/*!
+ \fn QByteArray QByteArray::trimmed() const
+
Returns a byte array that has whitespace removed from the start
and the end.
@@ -3229,11 +3238,17 @@ QByteArray QByteArray::simplified() const
\sa simplified()
*/
-QByteArray QByteArray::trimmed() const
+QByteArray QByteArray::trimmed_helper(const QByteArray &a)
{
- return QStringAlgorithms<const QByteArray>::trimmed_helper(*this);
+ return QStringAlgorithms<const QByteArray>::trimmed_helper(a);
}
+QByteArray QByteArray::trimmed_helper(QByteArray &a)
+{
+ return QStringAlgorithms<QByteArray>::trimmed_helper(a);
+}
+
+
/*!
Returns a byte array of size \a width that contains this byte
array padded by the \a fill character.