summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearray.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-07-28 20:46:18 -0700
committerThiago Macieira <thiago.macieira@intel.com>2014-08-19 03:39:30 +0200
commit55c1f54c5550848af9aa2ababb559b8f2346c912 (patch)
tree0b426db7202a334cc2c9f42cb9be0b39aa9db13a /src/corelib/tools/qbytearray.cpp
parent6dd759c8e947670f28dccba946138b7f8d609eaa (diff)
Add rvalue-ref qualified overload of QByteArray::to{Upper,Lower}
Those operations aren't very common with QByteArray but this is easy to optimize. Qt Qt Creator const & && const & && toLower 34 10 0 1 toUpper 3 1 0 0 Change-Id: I2097955f4c889ea5a21903c35ddbc0ff27bf62c5 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools/qbytearray.cpp')
-rw-r--r--src/corelib/tools/qbytearray.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 6b6a9d2c1a..8b2d48df66 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -2777,10 +2777,10 @@ static QByteArray toCase_template(T &input, const uchar * table)
}
if (firstBad == e)
- return input;
+ return qMove(input);
// transform the rest
- QByteArray s = input;
+ QByteArray s = qMove(input); // will copy if T is const QByteArray
char *b = s.begin(); // will detach if necessary
char *p = b + (firstBad - orig_begin);
e = b + s.size();
@@ -2790,13 +2790,19 @@ static QByteArray toCase_template(T &input, const uchar * table)
return s;
}
+QByteArray QByteArray::toLower_helper(const QByteArray &a)
+{
+ return toCase_template(a, latin1_lowercased);
+}
-QByteArray QByteArray::toLower() const
+QByteArray QByteArray::toLower_helper(QByteArray &a)
{
- return toCase_template(*this, latin1_lowercased);
+ return toCase_template(a, latin1_lowercased);
}
/*!
+ \fn QByteArray QByteArray::toUpper() const
+
Returns an uppercase copy of the byte array. The bytearray is
interpreted as a Latin-1 encoded string.
@@ -2805,9 +2811,15 @@ QByteArray QByteArray::toLower() const
\sa toLower(), {8-bit Character Comparisons}
*/
-QByteArray QByteArray::toUpper() const
+
+QByteArray QByteArray::toUpper_helper(const QByteArray &a)
+{
+ return toCase_template(a, latin1_uppercased);
+}
+
+QByteArray QByteArray::toUpper_helper(QByteArray &a)
{
- return toCase_template(*this, latin1_uppercased);
+ return toCase_template(a, latin1_uppercased);
}
/*! \fn void QByteArray::clear()