summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2016-10-07 10:59:11 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2016-10-14 10:17:51 +0000
commit936e13212248e32f92f24765b4dd919610253d6f (patch)
tree22a05edd08759259d6aaafd9c072cfa37124cd6c /src
parenta89734360154cb9bf2aebf05c5d115b970d79871 (diff)
Add optimize-for-size case to ucstrncmp
The SSE code had a case where tail-loop unrolling was disabled when optimizing for size. What would be even shorter, is to just do a straight-forward loop over the arrays and compare them. For anything else, we can just go for speed. Change-Id: Ifb31650e10e41409972a38014067dbd2927674c9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qstring.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index bf1bc3e650..26bb0de278 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -446,6 +446,16 @@ extern "C" int qt_ucstrncmp_mips_dsp_asm(const ushort *a,
// Unicode case-sensitive compare two same-sized strings
static int ucstrncmp(const QChar *a, const QChar *b, int l)
{
+#ifdef __OPTIMIZE_SIZE__
+ const QChar *end = a + l;
+ while (a < end) {
+ if (int diff = (int)a->unicode() - (int)b->unicode())
+ return diff;
+ ++a;
+ ++b;
+ }
+ return 0;
+#else
#if defined(__mips_dsp)
if (l >= 8) {
return qt_ucstrncmp_mips_dsp_asm(reinterpret_cast<const ushort*>(a),
@@ -473,7 +483,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
- reinterpret_cast<const QChar *>(ptr + distance + idx)->unicode();
}
}
-# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
+# if defined(Q_COMPILER_LAMBDA)
const auto &lambda = [=](int i) -> int {
return reinterpret_cast<const QChar *>(ptr)[i].unicode()
- reinterpret_cast<const QChar *>(ptr + distance)[i].unicode();
@@ -529,6 +539,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
}
}
return 0;
+#endif
}
static int ucstrncmp(const QChar *a, const uchar *c, int l)