-#if defined(__WXMSW__) && !wxUSE_UNICODE_UTF8
- // Prefer to use CompareString() if available as it's more efficient than
- // doing it manually or even using wxStricmp() (see #10375)
- //
- // Also note that not using NORM_STRINGSORT may result in not having a
- // strict weak ordering (e.g. s1 < s2 and s2 < s3 but s3 < s1) and so break
- // algorithms such as std::sort that rely on it. It's also more consistent
- // with the fall back version below.
- switch ( ::CompareString(LOCALE_USER_DEFAULT,
- NORM_IGNORECASE | SORT_STRINGSORT,
- m_impl.c_str(), m_impl.length(),
- s.m_impl.c_str(), s.m_impl.length()) )
+#if !wxUSE_UNICODE_UTF8
+ // We compare NUL-delimited chunks of the strings inside the loop. We will
+ // do as many iterations as there are embedded NULs in the string, i.e.
+ // usually we will run it just once.
+
+ typedef const wxStringImpl::value_type *pchar_type;
+ const pchar_type thisBegin = m_impl.c_str();
+ const pchar_type thatBegin = s.m_impl.c_str();
+
+ const pchar_type thisEnd = thisBegin + m_impl.length();
+ const pchar_type thatEnd = thatBegin + s.m_impl.length();
+
+ pchar_type thisCur = thisBegin;
+ pchar_type thatCur = thatBegin;
+
+ int rc;
+ for ( ;; )