summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs/qutfcodec.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-06-07 00:40:44 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-07 00:40:44 +0200
commitd9a7ad80f78e7346d6f4dbae2cabe31305d6458f (patch)
tree26a410780b94c553051b8898d5abaf37a909691b /src/corelib/codecs/qutfcodec.cpp
parentd707acfc9e357ffc86feb5d9219372c30c5ff157 (diff)
parent0fcce50af009f97efa2a5c5f2c74415c92830962 (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib/codecs/qutfcodec.cpp')
-rw-r--r--src/corelib/codecs/qutfcodec.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index f16144771f..9139e61700 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -74,25 +74,22 @@ static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const
__m128i packed = _mm_packus_epi16(data1, data2);
__m128i nonAscii = _mm_cmpgt_epi8(packed, _mm_setzero_si128());
+ // store, even if there are non-ASCII characters here
+ _mm_storeu_si128((__m128i*)dst, packed);
+
// n will contain 1 bit set per character in [data1, data2] that is non-ASCII (or NUL)
ushort n = ~_mm_movemask_epi8(nonAscii);
if (n) {
- // copy the front part that is still ASCII
- while (!(n & 1)) {
- *dst++ = *src++;
- n >>= 1;
- }
-
// find the next probable ASCII character
// we don't want to load 32 bytes again in this loop if we know there are non-ASCII
// characters still coming
- n = _bit_scan_reverse(n);
- nextAscii = src + n + 1;
+ nextAscii = src + _bit_scan_reverse(n) + 1;
+
+ n = _bit_scan_forward(n);
+ dst += n;
+ src += n;
return false;
}
-
- // pack
- _mm_storeu_si128((__m128i*)dst, packed);
}
return src == end;
}