Re: [Nautilus-list] Nautilus Performance Analysis



On Tue, 14 Aug 2001, Darin Adler wrote:

> On Tuesday, August 14, 2001, at 07:09  AM, Alan Cox wrote:
> 
> > -	Repeated reloads of /usr/share/eel/fonts/urw/n019003l.pfb
> 
> Maybe Ramiro can comment on this. One bit of good news is that Nautilus 
> won't have its own font handling at all if we do the GNOME 2 port well, so 
> this might just go away on its own as we port to GNOME 2.

The problem is in eel_scalable_font_new ():

EelScalableFont *
eel_scalable_font_new (const char *file_name)
{
	EelScalableFont *font;
	gpointer font_handle_as_pointer;
	RsvgFTFontHandle font_handle = -1;

	g_return_val_if_fail (eel_strlen (file_name) > 0, NULL);
	g_return_val_if_fail (eel_font_manager_file_is_scalable_font (file_name), NULL);

	initialize_global_stuff_if_needed ();



The eel_font_manager_file_is_scalable_font() call results in a call to 
gnome-vfs mimetype magic sniffing that opens the file and reads the 
beginning of it.

My patch gets this at an earlier stage though. The reason why 
eel_scalable_font_new() is called all the time is that 
eel_scalable_font_get_default_font() loads a new font each time it is 
called.

Here is my patch for this:

Index: eel/eel-scalable-font.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-scalable-font.c,v
retrieving revision 1.6
diff -u -p -r1.6 eel-scalable-font.c
--- eel/eel-scalable-font.c	2001/05/02 17:33:07	1.6
+++ eel/eel-scalable-font.c	2001/08/14 18:03:24
@@ -301,13 +301,17 @@ EelScalableFont *
 eel_scalable_font_get_default_font (void)
 {
 	char *default_font_file_name;
-	EelScalableFont *default_font;
+	static EelScalableFont *default_font = NULL;
 
-	default_font_file_name = eel_font_manager_get_default_font ();
-	g_assert (default_font_file_name != NULL);
-	default_font = eel_scalable_font_new (default_font_file_name);
-	g_free (default_font_file_name);
-	g_assert (EEL_IS_SCALABLE_FONT (default_font));
+	if (!default_font) {
+		default_font_file_name = eel_font_manager_get_default_font ();
+		g_assert (default_font_file_name != NULL);
+		default_font = eel_scalable_font_new (default_font_file_name);
+		g_free (default_font_file_name);
+		g_assert (EEL_IS_SCALABLE_FONT (default_font));
+	}
+
+	gtk_object_ref (GTK_OBJECT (default_font));
 	return default_font;
 }
 
@@ -315,13 +319,17 @@ EelScalableFont *
 eel_scalable_font_get_default_bold_font (void)
 {
 	char *default_bold_font_file_name;
-	EelScalableFont *default_bold_font;
+	static EelScalableFont *default_bold_font = NULL;
+
+	if (!default_bold_font) {
+		default_bold_font_file_name = eel_font_manager_get_default_bold_font ();
+		g_assert (default_bold_font_file_name != NULL);
+		default_bold_font = eel_scalable_font_new (default_bold_font_file_name);
+		g_free (default_bold_font_file_name);
+		g_assert (EEL_IS_SCALABLE_FONT (default_bold_font));
+	}
 
-	default_bold_font_file_name = eel_font_manager_get_default_bold_font ();
-	g_assert (default_bold_font_file_name != NULL);
-	default_bold_font = eel_scalable_font_new (default_bold_font_file_name);
-	g_free (default_bold_font_file_name);
-	g_assert (EEL_IS_SCALABLE_FONT (default_bold_font));
+	gtk_object_ref (GTK_OBJECT (default_bold_font));
 	return default_bold_font;
 }
 





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