summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-02-07 10:44:55 +0100
committerMarc Mutz <marc.mutz@kdab.com>2017-02-07 12:01:08 +0000
commit18e6e8105971df910ab3881ee36476432d17e382 (patch)
tree3bea17baca93a8bea565f653e21f991bd1ded75e /src/corelib/tools
parentee348975654bb5f659370118dcf7b4bb494add87 (diff)
QCollator/ICU: fix a rather hair-raising performance bug in compare(QChar*, int, QChar*, int)
The intention when using an overload that takes (const QChar*, int) instead of a QString is probably to avoid creating a QString in the first place. If the implementation stabbs the user in the back by internally creating a QString just so it can call QString::compare() on it, then that is rather unacceptable. QCollator is already a friend of QString, so, absent QStringView, resolve to calling compare_helper(). Change-Id: Ia7de1a095e3e310bd1b9957ed67291cc9cc95b32 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qcollator_icu.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp
index 3cde3051b4..1e94798c5b 100644
--- a/src/corelib/tools/qcollator_icu.cpp
+++ b/src/corelib/tools/qcollator_icu.cpp
@@ -110,7 +110,7 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con
if (d->collator)
return ucol_strcoll(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2);
- return QString::compare(QString(s1, len1), QString(s2, len2), d->caseSensitivity);
+ return QString::compare_helper(s1, len1, s2, len2, d->caseSensitivity);
}
int QCollator::compare(const QString &s1, const QString &s2) const