From 18e6e8105971df910ab3881ee36476432d17e382 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 7 Feb 2017 10:44:55 +0100 Subject: 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 --- src/corelib/tools/qcollator_icu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3