From ac2d749e8823f48aadc222b4da3011a90444ecf7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 22 Aug 2007 09:24:56 +0000 Subject: [PATCH] optimize wxStringOperationsUtf8::DecodeChar() for the ASCII case git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48321 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/stringops.h | 10 +++++++++- src/common/stringops.cpp | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/wx/stringops.h b/include/wx/stringops.h index b8ba8abd74..1aa44e5f67 100644 --- a/include/wx/stringops.h +++ b/include/wx/stringops.h @@ -156,7 +156,15 @@ struct WXDLLIMPEXP_BASE wxStringOperationsUtf8 } // decodes single UTF-8 character from UTF-8 string - static wxUniChar DecodeChar(wxStringImpl::const_iterator i); + static wxUniChar DecodeChar(wxStringImpl::const_iterator i) + { + if ( (unsigned char)*i < 0x80 ) + return (int)*i; + return DecodeNonAsciiChar(i); + } + +private: + static wxUniChar DecodeNonAsciiChar(wxStringImpl::const_iterator i); }; #endif // wxUSE_UNICODE_UTF8 diff --git a/src/common/stringops.cpp b/src/common/stringops.cpp index 2050048062..08d451492e 100644 --- a/src/common/stringops.cpp +++ b/src/common/stringops.cpp @@ -249,7 +249,7 @@ wxUniChar::Utf8CharBuffer wxUniChar::AsUTF8() const } wxUniChar -wxStringOperationsUtf8::DecodeChar(wxStringImpl::const_iterator i) +wxStringOperationsUtf8::DecodeNonAsciiChar(wxStringImpl::const_iterator i) { wxASSERT( IsValidUtf8LeadByte(*i) ); -- 2.47.2