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>
This commit is contained in:
Thiago Macieira 2014-01-16 17:59:45 -08:00 committed by The Qt Project
parent de1b98e9c1
commit fd0f1bc321
2 changed files with 14 additions and 5 deletions

View File

@ -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

View File

@ -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)
{