Re: GObject memory statistics



On Mon, 2006-07-17 at 09:00 +0100, ext Ross Burton wrote:
> On Fri, 2006-07-14 at 18:08 +0300, Tommi Komulainen wrote:
> > I think we should really look what iconv() and _pthread_once() do,
> > or get completely rid of iconv().  Currently it's needed for:
> > - Converting window titles from utf8 to latin1
> > - Converting png comment fields (containing hotspot etc info)
> >   from latin1 to utf8
> > - Doing filesystem file name conversions from/to latin1
> > 
> > 
> > Update: In IT-2006 software the need for iconv() is removed.
> 
> How do you remove iconv from the (say) window title utf-8 to latin1?
> Did you implement a very simple converter (an almost-identity array
> would be a quick and easy solution) inside GTK?  If so then I'd be
> interested to see that upstreamed.

By commenting out all legacy WM hints handling :)  I mean really,
_NET_WM_NAME is now how old? In our case it makes absolutely no sense to
use WM_NAME et. al., not sure it makes sense even on the GNOME desktop
these days. And that's all it takes to drag in iconv. That and png
comments.

See the attached patch[1]. I'd give a viewcvs link but our viewcvs is
apparently down.


1. svn diff -r2434:2436 https://stage.maemo.org/svn/maemo/projects/haf/trunk/gtk+

-- 
Tommi Komulainen                            <tommi komulainen nokia com>
Index: gdk-pixbuf/io-png.c
===================================================================
--- gdk-pixbuf/io-png.c	(revision 2434)
+++ gdk-pixbuf/io-png.c	(revision 2436)
@@ -204,14 +204,23 @@
                            gchar    **key,
                            gchar    **value)
 {
-        if (text_ptr.text_length > 0) {
-                *value = g_convert (text_ptr.text, -1, 
-                                    "UTF-8", "ISO-8859-1", 
-                                    NULL, NULL, NULL);
-        }
-        else {
-                *value = g_strdup (text_ptr.text);
-        }
+	gboolean is_ascii = TRUE;
+	int i;
+
+	/* Avoid loading iconv if the text is plain ASCII */
+	for (i = 0; i < text_ptr.text_length; i++)
+		if (text_ptr.text[i] & 0x80) {
+			is_ascii = FALSE;
+			break;
+		}
+
+	if (is_ascii)
+		*value = g_strdup (text_ptr.text);
+	else
+		*value = g_convert (text_ptr.text, -1, 
+				    "UTF-8", "ISO-8859-1", 
+				    NULL, NULL, NULL);
+
         if (*value) {
                 *key = g_strconcat ("tEXt::", text_ptr.key, NULL);
                 return TRUE;
Index: gdk-pixbuf/ChangeLog
===================================================================
--- gdk-pixbuf/ChangeLog	(revision 2434)
+++ gdk-pixbuf/ChangeLog	(revision 2436)
@@ -1,3 +1,8 @@
+2006-02-22  Tommi Komulainen  <tommi komulainen nokia com>
+
+	* io-png.c (png_text_to_pixbuf_option): Avoid loading iconv if the
+	text is plain ASCII as it wastes quite a bit of memory for no benefit.
+
 2006-01-30  Tommi Komulainen  <tommi komulainen nokia com>
 
 	Merge from GNOME CVS.
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 2434)
+++ ChangeLog	(revision 2436)
@@ -1,4 +1,11 @@
 2006-02-22  Tommi Komulainen  <tommi komulainen nokia com>
+	
+	* gdk/x11/gdkwindow-x11.c (set_wm_name, gdk_window_set_title,
+	gdk_window_set_icon_name): Set non-UTF-8 legacy WM hints only if
+	ENABLE_ICCCM_LEGACY is defined. Avoids needlessly loading iconv as it
+	wastes quite a bit of memory for no benefit.
+
+2006-02-22  Tommi Komulainen  <tommi komulainen nokia com>
 
 	* */*.c: Add missing Since: tags for custom additions
 	* docs/reference/gtk/gtk-sections: Add missing symbols
Index: gdk/x11/gdkwindow-x11.c
===================================================================
--- gdk/x11/gdkwindow-x11.c	(revision 2434)
+++ gdk/x11/gdkwindow-x11.c	(revision 2436)
@@ -2644,6 +2644,7 @@
     }
 }
 
+#ifdef ENABLE_ICCCM_LEGACY
 static gboolean
 utf8_is_latin1 (const gchar *str)
 {
@@ -2711,6 +2712,7 @@
 	g_free (prop_text);
     }
 }
+#endif
 
 /* Set WM_NAME and _NET_WM_NAME
  */
@@ -2724,9 +2726,11 @@
 		   gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
 		   PropModeReplace, name, strlen (name));
   
+#ifdef ENABLE_ICCCM_LEGACY
   set_text_property (display, xwindow,
 		     gdk_x11_get_xatom_by_name_for_display (display, "WM_NAME"),
 		     name);
+#endif
 }
 
 /**
@@ -2768,9 +2772,11 @@
 		       gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
 		       PropModeReplace, title, strlen (title));
       
+#ifdef ENABLE_ICCCM_LEGACY
       set_text_property (display, xwindow,
 			 gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
 			 title);
+#endif
     }
 }
 
@@ -4114,10 +4120,12 @@
 		   gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
 		   gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
 		   PropModeReplace, name, strlen (name));
-  
+
+#ifdef ENABLE_ICCCM_LEGACY
   set_text_property (display, GDK_WINDOW_XID (window),
 		     gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
 		     name);
+#endif
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]