summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-01-12 19:56:32 -0800
committerThiago Macieira <thiago.macieira@intel.com>2022-12-04 17:56:45 -0800
commit3b528670e6d5cbe25e0892b484b3e93417e263d3 (patch)
treeaf0537c4ca89a77f507950bb56db1afa0eb1e0f7 /src/corelib
parent23f1d68b091e91024f670d176d14cdc2995d56f4 (diff)
QString::toLatin1/SSE: simplify the code to merge question marks
Just move the test of Checked into the lambda, so we can call it unconditionally. Change-Id: I0e5f6bec596a4a78bd3bfffd16c9b84ff4a31bb9 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/text/qstring.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 49e26d7615..90e791d0d3 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -884,6 +884,9 @@ static void qt_to_latin1_internal(uchar *dst, const char16_t *src, qsizetype len
}
auto mergeQuestionMarks = [=](__m128i chunk) {
+ if (!Checked)
+ return chunk;
+
// SSE has no compare instruction for unsigned comparison.
if constexpr (UseSse4_1) {
// We use an unsigned uc = qMin(uc, 0x100) and then compare for equality.
@@ -930,12 +933,10 @@ static void qt_to_latin1_internal(uchar *dst, const char16_t *src, qsizetype len
chunk1 = _mm256_castsi256_si128(chunk);
} else {
chunk1 = _mm_loadu_si128((const __m128i*)(src + offset)); // load
- if (Checked)
- chunk1 = mergeQuestionMarks(chunk1);
+ chunk1 = mergeQuestionMarks(chunk1);
chunk2 = _mm_loadu_si128((const __m128i*)(src + offset + 8)); // load
- if (Checked)
- chunk2 = mergeQuestionMarks(chunk2);
+ chunk2 = mergeQuestionMarks(chunk2);
}
// pack the two vector to 16 x 8bits elements
@@ -947,8 +948,7 @@ static void qt_to_latin1_internal(uchar *dst, const char16_t *src, qsizetype len
// we're going to write to dst[offset..offset+7] (8 bytes)
if (dst + offset + 7 < e) {
__m128i chunk = _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + offset));
- if (Checked)
- chunk = mergeQuestionMarks(chunk);
+ chunk = mergeQuestionMarks(chunk);
// pack, where the upper half is ignored
const __m128i result = _mm_packus_epi16(chunk, chunk);
@@ -959,8 +959,7 @@ static void qt_to_latin1_internal(uchar *dst, const char16_t *src, qsizetype len
// we're going to write to dst[offset..offset+3] (4 bytes)
if (dst + offset + 3 < e) {
__m128i chunk = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(src + offset));
- if (Checked)
- chunk = mergeQuestionMarks(chunk);
+ chunk = mergeQuestionMarks(chunk);
// pack, we'll the upper three quarters
const __m128i result = _mm_packus_epi16(chunk, chunk);