diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-01-16 17:59:45 -0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-08 06:09:57 +0100 |
commit | fd0f1bc321a684a0dd57329943f1e6264f8fc7c6 (patch) | |
tree | e437e5276da5372fe6dfd921b2f592da544af200 | |
parent | de1b98e9c16afd1f428652e800cbeb35414b2b4f (diff) |
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 <ogoffart@woboq.com>
-rw-r--r-- | src/corelib/tools/qstring.cpp | 10 | ||||
-rw-r--r-- | src/corelib/tools/qstringbuilder.h | 9 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 2c6c5b7057..33dfbdb9c3 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -54,6 +54,7 @@ #include <qlist.h> #include "qlocale.h" #include "qlocale_p.h" +#include "qstringbuilder.h" #include "qstringmatcher.h" #include "qvarlengtharray.h" #include "qtools_p.h" @@ -9988,4 +9989,13 @@ QString QString::toHtmlEscaped() const \endlist */ + +/*! + \internal + */ +void QAbstractConcatenable::appendLatin1To(const char *a, int len, QChar *out) +{ + qt_from_latin1(reinterpret_cast<ushort *>(out), a, uint(len)); +} + QT_END_NAMESPACE 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 <typename T> struct QConcatenable {}; @@ -222,7 +223,7 @@ template <> struct QConcatenable<QCharRef> : private QAbstractConcatenable { *out++ = QChar(c); } }; -template <> struct QConcatenable<QLatin1String> +template <> struct QConcatenable<QLatin1String> : private QAbstractConcatenable { typedef QLatin1String type; typedef QString ConvertTo; @@ -230,10 +231,8 @@ template <> struct QConcatenable<QLatin1String> 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) { |