summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-12-20 00:00:39 -0300
committerThiago Macieira <thiago.macieira@intel.com>2022-12-04 17:56:45 -0800
commit3ef43ca837b36cd0aefc925ea08234395dcf49e2 (patch)
tree7ea94b4d2acf0dc9a15a138c6c6659e7f96c580e /tests/auto
parent2b9d4afc95a6e716f7bb1839df4041e454aa52af (diff)
QString::fromLatin1: improve the sub-16-character case
For both the [4, 7] and [8,15] length cases, we can perform the same technique: perform two overlapped loads, zero-extend, then perform two overlapped stores. The 8-character case could be done in a single load/store pair, but is not worth the extra conditionals. And it should have the exact same performance numbers whether we use non-overlapping 4-character operations or completely-overlapping 8-character ones (I *think* the full overlap is actually better). The 4-character operation is new in this commit. That reduces the non-vectorized, unrolled to at most 3 characters. Change-Id: Ib42b3adc93bf4d43bd55fffd16c257ada774236a Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/text/qstring/tst_qstring.cpp49
1 files changed, 38 insertions, 11 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp
index 65c9e086cc..0d0c38d51f 100644
--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
@@ -5295,19 +5295,46 @@ void tst_QString::fromLatin1Roundtrip()
QCOMPARE(latin1.isEmpty(), unicode.isEmpty());
QCOMPARE(latin1.size(), unicode.size());
- if (!latin1.isEmpty())
- while (latin1.size() < 128) {
- latin1 += latin1;
- unicode += unicode;
- }
+ auto roundtripTest = [&]() {
+ // fromLatin1
+ QString fromLatin1 = QString::fromLatin1(latin1, latin1.length());
+ QCOMPARE(fromLatin1.length(), unicode.length());
+ QCOMPARE(fromLatin1, unicode);
+
+ // and back:
+ QByteArray toLatin1 = unicode.toLatin1();
+ QCOMPARE(toLatin1.length(), latin1.length());
+ QCOMPARE(toLatin1, latin1);
+ };
- // fromLatin1
- QCOMPARE(QString::fromLatin1(latin1, latin1.size()).size(), unicode.size());
- QCOMPARE(QString::fromLatin1(latin1, latin1.size()), unicode);
+ roundtripTest();
- // and back:
- QCOMPARE(unicode.toLatin1().size(), latin1.size());
- QCOMPARE(unicode.toLatin1(), latin1);
+ if (latin1.isEmpty())
+ return;
+
+ if (QTest::currentTestFailed()) QFAIL("failed");
+ while (latin1.length() < 16) {
+ latin1 += latin1;
+ unicode += unicode;
+ }
+ roundtripTest();
+
+ // double again (length will be > 32)
+ if (QTest::currentTestFailed()) QFAIL("failed");
+ latin1 += latin1;
+ unicode += unicode;
+ roundtripTest();
+
+ // double again (length will be > 64)
+ if (QTest::currentTestFailed()) QFAIL("failed");
+ latin1 += latin1;
+ unicode += unicode;
+ roundtripTest();
+
+ if (QTest::currentTestFailed()) QFAIL("failed");
+ latin1 += latin1;
+ unicode += unicode;
+ roundtripTest();
}
void tst_QString::toLatin1Roundtrip_data()