From fd0f1bc321a684a0dd57329943f1e6264f8fc7c6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jan 2014 17:59:45 -0800 Subject: Make QStringBuilder use our qt_from_latin1 code (out-of-line) Disassembly shows that the compiler does not perform the zero-expansion by itself. It always opts to copy byte-by-byte, which is not very performant. Change-Id: I08780902461d9e3e6b7b54298f41d1eca61339c4 Reviewed-by: Olivier Goffart --- src/corelib/tools/qstringbuilder.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/corelib/tools/qstringbuilder.h') diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 489357f5fd..f0670999d7 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -65,6 +65,7 @@ protected: { *out++ = QLatin1Char(a); } + static void appendLatin1To(const char *a, int len, QChar *out); }; template struct QConcatenable {}; @@ -222,7 +223,7 @@ template <> struct QConcatenable : private QAbstractConcatenable { *out++ = QChar(c); } }; -template <> struct QConcatenable +template <> struct QConcatenable : private QAbstractConcatenable { typedef QLatin1String type; typedef QString ConvertTo; @@ -230,10 +231,8 @@ template <> struct QConcatenable static int size(const QLatin1String a) { return a.size(); } static inline void appendTo(const QLatin1String a, QChar *&out) { - if (a.data()) { - for (const char *s = a.data(); *s; ) - *out++ = QLatin1Char(*s++); - } + appendLatin1To(a.latin1(), a.size(), out); + out += a.size(); } static inline void appendTo(const QLatin1String a, char *&out) { -- cgit v1.2.3