cache G_BROKEN_FILENAMES



Caching the value of getenv("G_BROKEN_FILENAMES") helps nautilus 
performance some (getenv showed up as number two in the profile)

Index: glib/gconvert.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gconvert.c,v
retrieving revision 1.34
diff -u -p -r1.34 gconvert.c
--- glib/gconvert.c	8 Mar 2002 15:50:53 -0000	1.34
+++ glib/gconvert.c	10 Mar 2002 18:31:55 -0000
@@ -1189,6 +1189,24 @@ g_locale_from_utf8 (const gchar *utf8str
 #endif /* !G_PLATFORM_WIN32 */
 }
 
+#ifndef G_PLATFORM_WIN32
+static gboolean
+have_broken_filenames (void)
+{
+  static gboolean initialized = FALSE;
+  static gboolean broken;
+  
+  if (initialized)
+    return broken;
+
+  broken = (getenv ("G_BROKEN_FILENAMES") != NULL);
+  
+  initialized = TRUE;
+  
+  return broken;
+}
+#endif /* !G_PLATFORM_WIN32 */
+  
 /**
  * g_filename_to_utf8:
  * @opsysstring:   a string in the encoding for filenames
@@ -1225,7 +1243,7 @@ g_filename_to_utf8 (const gchar *opsysst
 			   error);
 #else  /* !G_PLATFORM_WIN32 */
       
-  if (getenv ("G_BROKEN_FILENAMES"))
+  if (have_broken_filenames ())
     return g_locale_to_utf8 (opsysstring, len,
 			     bytes_read, bytes_written,
 			     error);
@@ -1268,7 +1286,7 @@ g_filename_from_utf8 (const gchar *utf8s
 			     bytes_read, bytes_written,
 			     error);
 #else  /* !G_PLATFORM_WIN32 */
-  if (getenv ("G_BROKEN_FILENAMES"))
+  if (have_broken_filenames ())
     return g_locale_from_utf8 (utf8string, len,
 			       bytes_read, bytes_written,
 			       error);

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a short-sighted Republican inventor possessed of the uncanny powers of an 
insect. She's an orphaned nymphomaniac college professor from Mars. They fight 
crime! 





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