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
This commit is contained in:
Vadim Zeitlin
2005-09-18 16:41:22 +00:00
parent ce6f8d6fb3
commit 35d10652f4

View File

@@ -1233,15 +1233,28 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
#endif // wxUSE_FONTMAP #endif // wxUSE_FONTMAP
#if wxUSE_WCHAR_T #if wxUSE_WCHAR_T
wxCSConv *csConv = NULL; // conversion to use to convert catalog strings to the GUI encoding
if ( !m_charset.empty() ) wxMBConv *inputConv,
csConv = new wxCSConv(m_charset); *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;
}
wxMBConv& inputConv = csConv ? *((wxMBConv*)csConv) : *wxConvCurrent; // 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
wxCSConv *sourceConv = NULL; // encoding as the catalog
if ( !msgIdCharset.empty() && (m_charset != msgIdCharset) ) wxCSConv *sourceConv = msgIdCharset.empty() || (msgIdCharset == m_charset)
sourceConv = new wxCSConv(msgIdCharset); ? NULL
: new wxCSConv(msgIdCharset);
#elif wxUSE_FONTMAP #elif wxUSE_FONTMAP
wxASSERT_MSG( msgIdCharset == NULL, wxASSERT_MSG( msgIdCharset == NULL,
@@ -1284,12 +1297,12 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
{ {
const char *data = StringAtOfs(m_pOrigTable, i); const char *data = StringAtOfs(m_pOrigTable, i);
#if wxUSE_UNICODE #if wxUSE_UNICODE
wxString msgid(data, inputConv); wxString msgid(data, *inputConv);
#else #else // ASCII
wxString msgid; wxString msgid;
#if wxUSE_WCHAR_T #if wxUSE_WCHAR_T
if ( convertEncoding && sourceConv ) if ( inputConv && sourceConv )
msgid = wxString(inputConv.cMB2WC(data), *sourceConv); msgid = wxString(inputConv->cMB2WC(data), *sourceConv);
else else
#endif #endif
msgid = data; msgid = data;
@@ -1304,10 +1317,10 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
wxString msgstr; wxString msgstr;
#if wxUSE_WCHAR_T #if wxUSE_WCHAR_T
#if wxUSE_UNICODE #if wxUSE_UNICODE
msgstr = wxString(data + offset, inputConv); msgstr = wxString(data + offset, *inputConv);
#else #else
if ( convertEncoding ) if ( inputConv )
msgstr = wxString(inputConv.cMB2WC(data + offset), wxConvLocal); msgstr = wxString(inputConv->cMB2WC(data + offset), wxConvLocal);
else else
msgstr = wxString(data + offset); msgstr = wxString(data + offset);
#endif #endif