From 55c1f54c5550848af9aa2ababb559b8f2346c912 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 28 Jul 2014 20:46:18 -0700 Subject: 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 Reviewed-by: Olivier Goffart --- src/corelib/tools/qbytearray.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/corelib/tools/qbytearray.h') diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index ba7fdbb10a..cb1ebf8493 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -264,8 +264,29 @@ public: void truncate(int pos); void chop(int n); +#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) +# if defined(Q_CC_GNU) + // required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941 +# pragma push_macro("Q_REQUIRED_RESULT") +# undef Q_REQUIRED_RESULT +# define Q_REQUIRED_RESULT +# define Q_REQUIRED_RESULT_pushed +# endif + QByteArray toLower() const & Q_REQUIRED_RESULT + { return toLower_helper(*this); } + QByteArray toLower() && Q_REQUIRED_RESULT + { return toLower_helper(*this); } + QByteArray toUpper() const & Q_REQUIRED_RESULT + { return toUpper_helper(*this); } + QByteArray toUpper() && Q_REQUIRED_RESULT + { return toUpper_helper(*this); } +# ifdef Q_REQUIRED_RESULT_pushed +# pragma pop_macro("Q_REQUIRED_RESULT") +# endif +#else QByteArray toLower() const Q_REQUIRED_RESULT; QByteArray toUpper() const Q_REQUIRED_RESULT; +#endif QByteArray trimmed() const Q_REQUIRED_RESULT; QByteArray simplified() const Q_REQUIRED_RESULT; @@ -422,6 +443,10 @@ private: void expand(int i); QByteArray nulTerminated() const; + static QByteArray toLower_helper(const QByteArray &a); + static QByteArray toLower_helper(QByteArray &a); + static QByteArray toUpper_helper(const QByteArray &a); + static QByteArray toUpper_helper(QByteArray &a); friend class QByteRef; friend class QString; friend Q_CORE_EXPORT QByteArray qUncompress(const uchar *data, int nbytes); -- cgit v1.2.3