Index: markup-tree.c
===================================================================
RCS file: /cvs/gnome/gconf/backends/markup-tree.c,v
retrieving revision 1.17
diff -u -r1.17 markup-tree.c
--- markup-tree.c	18 Mar 2005 15:08:10 -0000	1.17
+++ markup-tree.c	9 Jun 2005 10:48:22 -0000
@@ -33,6 +33,11 @@
 #include <stdio.h>
 #include <time.h>
 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+
 typedef struct
 {
   char       *locale;
@@ -163,12 +168,21 @@
   tree->root = markup_dir_new (tree, NULL, "/");  
 }
 
+typedef struct
+{
+	guchar *text;
+	int fd;
+	struct stat statbuf;
+} parsed_file_info_t;
+	
 struct _MarkupDir
 {
   MarkupTree *tree;
   MarkupDir *parent;
   char *name;
 
+  parsed_file_info_t *info;
+
   GSList *entries;
   GSList *subdirs;
 
@@ -243,7 +257,16 @@
 
   g_free (dir->name);
 
+  if (dir->info)
+  {
+    munmap (dir->info->text, dir->info->statbuf.st_size);
+
+    close (dir->info->fd); 
+    g_free (dir->info);
+  }
+
   g_free (dir);
+  
 }
 
 static void
@@ -3141,7 +3164,9 @@
   char *filename;
   char *text;
   gsize length;
-
+  
+  root->info = g_new0(parsed_file_info_t,1);
+  
   filename = markup_dir_build_file_path (root, parse_subtree);
   
   parse_info_init (&info, root, parse_subtree);
@@ -3149,11 +3174,17 @@
   text = NULL;
   length = 0;
   error = NULL;
-  if (!g_file_get_contents (filename, &text, &length, &error))
-    goto out;
+  g_print ("DOING MMAP\n");
+  if ((root->info->fd = open (filename, O_RDONLY)) == -1)
+	  goto out;
+  if (fstat (root->info->fd,&root->info->statbuf) < 0)
+	  goto out;
+  if ((root->info->text = (guchar*)mmap (0, root->info->statbuf.st_size, PROT_READ, MAP_SHARED, root->info->fd, 0)) == (guchar*) -1)
+	  goto out;
 
+  
   /* Empty documents are OK */
-  if (length == 0)
+  if (root->info->statbuf.st_size == 0)
     goto out;
 
   g_assert (text);
@@ -3163,8 +3194,8 @@
 
   error = NULL;
   if (!g_markup_parse_context_parse (context,
-                                     text,
-                                     length,
+                                     root->info->text,
+                                     root->info->statbuf.st_size,
                                      &error))
     goto out;
 
@@ -3177,7 +3208,6 @@
  out:
 
   g_free (filename);
-  g_free (text);
   parse_info_free (&info);
 
   if (error)
