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>bb10
parent
a897343601
commit
936e132122
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue