path: root/tests/auto
diff options
authorLars Knoll <>2014-01-21 10:35:01 +0100
committerThe Qt Project <>2014-03-27 07:31:01 +0100
commit5279134935e858e6fa8565c936b17e88d7bded50 (patch)
tree44c18903fdbac0fbff521bf0061094bfdf113a76 /tests/auto
parent5b00bb39f2f079e4745a0ca6f3a8c56e18bd2775 (diff)
Reuse one QCollator instance for QString::localeAwareCompare
Constructing a QCollator is somewhat expensive, and made localeAwareCompare really slow. As QCollator (at least with the ICU implementation) is not thread safe, use one collator per thread. This speeds up collation of a long list of strings by a factor of 250 for the test case in the bug below. Task-number: QTBUG-36149 Change-Id: I645cdc3546347d1dcc7a03b7563b628c7f756944 Reviewed-by: Thiago Macieira <> Reviewed-by: Konstantin Ritt <>
Diffstat (limited to 'tests/auto')
1 files changed, 2 insertions, 4 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 629a095f9d..5655d9f529 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -4876,10 +4876,8 @@ void tst_QString::localeAwareCompare()
DWORD oldLcid = GetUserDefaultLCID();
QCOMPARE(locale, GetUserDefaultLCID());
-#elif defined (Q_OS_MAC)
- QSKIP("Setting the locale is not supported on OS X (you can set the C locale, but that won't affect CFStringCompare which is used to compare strings)");
-#elif defined(QT_USE_ICU)
- QLocale::setDefault(QLocale(locale));
+#elif defined (Q_OS_MAC) || defined(QT_USE_ICU)
+ QSKIP("Setting the locale is not supported on OS X or ICU (you can set the C locale, but that won't affect localeAwareCompare)");
if (!locale.isEmpty()) {
const char *newLocale = setlocale(LC_ALL, locale.toLatin1());