From 4d3ca81b0aeef6f6496f3e89451f5369ce5efa99 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 19 Feb 2010 12:26:32 +0100 Subject: QStringBuilder: reduce the size of the generated code A simple concatenation of 2 string does not benefit from the QStringBuilder trick, yet, this would produce more code with QT_USE_FAST_OPERATOR_PLUS This commit specialize the QStringBuilder with two QString so it produce the same code as without it. Reviewed-by: joao Reviewed-by: hjk --- src/corelib/tools/qstringbuilder.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 74661c2..4ff1b36 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -117,6 +117,20 @@ public: }; +template <> +class QStringBuilder +{ + public: + QStringBuilder(const QString &a_, const QString &b_) : a(a_), b(b_) {} + + operator QString() const + { QString r(a); r += b; return r; } + QByteArray toLatin1() const { return QString(*this).toLatin1(); } + + const QString &a; + const QString &b; +}; + template <> struct QConcatenable : private QAbstractConcatenable { typedef char type; -- cgit v0.12