]> git.saurik.com Git - wxWidgets.git/commitdiff
don't create conversion objects unless we really need to convert
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 18 Sep 2005 16:41:22 +0000 (16:41 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 18 Sep 2005 16:41:22 +0000 (16:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35572 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/intl.cpp

index fd08730d8e3b68969325e797e8b574eadc1d0b99..bf4973dbcb10ed615f844dd8eec6a2cfffe46332 100644 (file)
@@ -1233,15 +1233,28 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
 #endif // wxUSE_FONTMAP
 
 #if wxUSE_WCHAR_T
 #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,
 
 #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
     {
         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
         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;
         else
 #endif
             msgid = data;
@@ -1304,10 +1317,10 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
             wxString msgstr;
 #if wxUSE_WCHAR_T
         #if wxUSE_UNICODE
             wxString msgstr;
 #if wxUSE_WCHAR_T
         #if wxUSE_UNICODE
-            msgstr = wxString(data + offset, inputConv);
+            msgstr = wxString(data + offset, *inputConv);
         #else
         #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
             else
                 msgstr = wxString(data + offset);
         #endif