From: Vadim Zeitlin Date: Sun, 18 Sep 2005 16:41:22 +0000 (+0000) Subject: don't create conversion objects unless we really need to convert X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/35d10652f49a9adcc61ff242be331f07cf785175 don't create conversion objects unless we really need to convert git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35572 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/intl.cpp b/src/common/intl.cpp index fd08730d8e..bf4973dbcb 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -1233,15 +1233,28 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, #endif // wxUSE_FONTMAP #if wxUSE_WCHAR_T - wxCSConv *csConv = NULL; - if ( !m_charset.empty() ) - csConv = new wxCSConv(m_charset); - - wxMBConv& inputConv = csConv ? *((wxMBConv*)csConv) : *wxConvCurrent; + // conversion to use to convert catalog strings to the GUI encoding + wxMBConv *inputConv, + *csConv = NULL; // another ptr just to be able to delete it later + if ( convertEncoding ) + { + if ( m_charset.empty() ) + inputConv = wxConvCurrent; + else + inputConv = + csConv = new wxCSConv(m_charset); + } + else // no conversion needed + { + inputConv = NULL; + } - wxCSConv *sourceConv = NULL; - if ( !msgIdCharset.empty() && (m_charset != msgIdCharset) ) - sourceConv = new wxCSConv(msgIdCharset); + // conversion to apply to msgid strings before looking them up: we only + // need it if the msgids are neither in 7 bit ASCII nor in the same + // encoding as the catalog + wxCSConv *sourceConv = msgIdCharset.empty() || (msgIdCharset == m_charset) + ? NULL + : new wxCSConv(msgIdCharset); #elif wxUSE_FONTMAP wxASSERT_MSG( msgIdCharset == NULL, @@ -1284,12 +1297,12 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, { const char *data = StringAtOfs(m_pOrigTable, i); #if wxUSE_UNICODE - wxString msgid(data, inputConv); -#else + wxString msgid(data, *inputConv); +#else // ASCII wxString msgid; #if wxUSE_WCHAR_T - if ( convertEncoding && sourceConv ) - msgid = wxString(inputConv.cMB2WC(data), *sourceConv); + if ( inputConv && sourceConv ) + msgid = wxString(inputConv->cMB2WC(data), *sourceConv); else #endif msgid = data; @@ -1304,10 +1317,10 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, wxString msgstr; #if wxUSE_WCHAR_T #if wxUSE_UNICODE - msgstr = wxString(data + offset, inputConv); + msgstr = wxString(data + offset, *inputConv); #else - if ( convertEncoding ) - msgstr = wxString(inputConv.cMB2WC(data + offset), wxConvLocal); + if ( inputConv ) + msgstr = wxString(inputConv->cMB2WC(data + offset), wxConvLocal); else msgstr = wxString(data + offset); #endif