summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-04-11 23:01:43 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-11 23:01:43 +0200
commit4c1e15548a288455a5a62dcefacd7c9a44736346 (patch)
tree0273cad922b92b008870808fb67403131383313e /src/corelib/tools
parentc501eb8bece9c9de37f7f0839a8396fbfa697fec (diff)
parent98d3e40fb7c88b670a93e73dace2d0f05a5f903c (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qbytearray.h2
-rw-r--r--src/corelib/tools/qstring.cpp18
2 files changed, 13 insertions, 7 deletions
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index b0a6971964..0a2f7a9e53 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -462,7 +462,7 @@ inline int QByteArray::capacity() const
inline void QByteArray::reserve(int asize)
{
if (d->ref.isShared() || uint(asize) + 1u > d->alloc) {
- reallocData(uint(asize) + 1u, d->detachFlags() | Data::CapacityReserved);
+ reallocData(qMax(uint(size()), uint(asize)) + 1u, d->detachFlags() | Data::CapacityReserved);
} else {
// cannot set unconditionally, since d could be the shared_null or
// otherwise static
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 01faad6f2d..79365b11b1 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -559,11 +559,13 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
}
}
- // we'll read uc[offset..offset+7] (16 bytes) and c[offset-8..offset+7] (16 bytes)
+# ifdef Q_PROCESSOR_X86_64
+ enum { MaxTailLength = 7 };
+ // we'll read uc[offset..offset+7] (16 bytes) and c[offset..offset+7] (8 bytes)
if (uc + offset + 7 < e) {
- // same, but we'll throw away half the data
- __m128i chunk = _mm_loadu_si128((__m128i*)(c + offset - 8));
- __m128i secondHalf = _mm_unpackhi_epi8(chunk, nullmask);
+ // same, but we're using an 8-byte load
+ __m128i chunk = _mm_cvtsi64_si128(*(long long *)(c + offset));
+ __m128i secondHalf = _mm_unpacklo_epi8(chunk, nullmask);
__m128i ucdata = _mm_loadu_si128((__m128i*)(uc + offset));
__m128i result = _mm_cmpeq_epi16(secondHalf, ucdata);
@@ -577,6 +579,10 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
// still matched
offset += 8;
}
+# else
+ // 32-bit, we can't do MOVQ to load 8 bytes
+ enum { MaxTailLength = 15 };
+# endif
// reset uc and c
uc += offset;
@@ -584,7 +590,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
# ifdef Q_COMPILER_LAMBDA
const auto &lambda = [=](int i) { return uc[i] - ushort(c[i]); };
- return UnrollTailLoop<7>::exec(e - uc, 0, lambda, lambda);
+ return UnrollTailLoop<MaxTailLength>::exec(e - uc, 0, lambda, lambda);
# endif
#endif
@@ -5320,7 +5326,7 @@ int QString::localeAwareCompare(const QString &other) const
return localeAwareCompare_helper(constData(), length(), other.constData(), other.length());
}
-#if defined(QT_USE_ICU)
+#if defined(QT_USE_ICU) && !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE) && !defined (Q_OS_MAC)
Q_GLOBAL_STATIC(QThreadStorage<QCollator>, defaultCollator)
#endif