Don't use native MSW functions in wxString::CmpNoCase().

While the native CompareString() is much more efficient than MSVC CRT version
of _wcsicmp(), it gives unexpected results for non-letter characters, so don't
use it but use the slow but correct wxStricmp() instead.

At least don't use char-by-char comparison (in non-UTF-8 case) as it's the
slowest possible implementation of this function, the new one using
wxStricmp() is 3 times faster (by comparison, using CompareString() is 16
times faster still -- but wrong).

Closes #10375.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65572 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-09-20 12:52:26 +00:00
parent 05f68f2f84
commit 5858fe6806
2 changed files with 59 additions and 27 deletions

View File

@@ -455,6 +455,10 @@ void StringTestCase::Compare()
CPPUNIT_ASSERT( s1 != neq2 );
CPPUNIT_ASSERT( s1 != neq3 );
CPPUNIT_ASSERT( s1 != neq4 );
CPPUNIT_ASSERT( wxString("\n").Cmp(" ") < 0 );
CPPUNIT_ASSERT( wxString("'").Cmp("!") > 0 );
CPPUNIT_ASSERT( wxString("!").Cmp("z") < 0 );
}
void StringTestCase::CompareNoCase()
@@ -502,6 +506,10 @@ void StringTestCase::CompareNoCase()
CPPUNIT_CNCNEQ_ASSERT( s1, neq );
CPPUNIT_CNCNEQ_ASSERT( s1, neq2 );
CPPUNIT_CNCNEQ_ASSERT( s1, neq3 );
CPPUNIT_ASSERT( wxString("\n").CmpNoCase(" ") < 0 );
CPPUNIT_ASSERT( wxString("'").CmpNoCase("!") > 0);
CPPUNIT_ASSERT( wxString("!").Cmp("Z") < 0 );
}
void StringTestCase::Contains()