From: Paul Cornett <paulcor@bullseye.com>
Date: Thu, 27 Dec 2007 03:04:56 +0000 (+0000)
Subject: speed up XPM decoding 30-40% by not creating temporary wxString for each pixel
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a59e42ee313e595adb6d8ead58d09bdf846f02fe

speed up XPM decoding 30-40% by not creating temporary wxString for each pixel

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50922 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/common/xpmdecod.cpp b/src/common/xpmdecod.cpp
index b866d751aa..27d1127aa8 100644
--- a/src/common/xpmdecod.cpp
+++ b/src/common/xpmdecod.cpp
@@ -664,7 +664,7 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data)
     int count;
     unsigned width, height, colors_cnt, chars_per_pixel;
     size_t i, j, i_key;
-    wxChar key[64];
+    char key[64];
     const char *clr_def;
     bool hasMask;
     wxXPMColourMap clr_tbl;
@@ -692,7 +692,7 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data)
         return wxNullImage;
 
     img.SetMask(false);
-    key[chars_per_pixel] = wxT('\0');
+    key[chars_per_pixel] = '\0';
     hasMask = false;
 
     /*
@@ -712,7 +712,7 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data)
         }
 
         for (i_key = 0; i_key < chars_per_pixel; i_key++)
-            key[i_key] = (wxChar)xmpColLine[i_key];
+            key[i_key] = xmpColLine[i_key];
         clr_def = ParseColor(xmpColLine + chars_per_pixel);
 
         if ( clr_def == NULL )
@@ -766,6 +766,7 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data)
     unsigned char *img_data = img.GetData();
     wxXPMColourMap::iterator entry;
     wxXPMColourMap::iterator end = clr_tbl.end();
+    wxString keyString;
 
     for (j = 0; j < height; j++)
     {
@@ -781,10 +782,11 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data)
 
             for (i_key = 0; i_key < chars_per_pixel; i_key++)
             {
-                key[i_key] = (wxChar)xpmImgLine[chars_per_pixel * i + i_key];
+                key[i_key] = xpmImgLine[chars_per_pixel * i + i_key];
             }
 
-            entry = clr_tbl.find(key);
+            keyString = key;
+            entry = clr_tbl.find(keyString);
             if ( entry == end )
             {
                 wxLogError(_("XPM: Malformed pixel data!"));