[hacktree] src: Only use local VFS - this avoids hitting up the session bus



commit a06f724b724ae8ae6dca5c5ae8a17e6cd8055c77
Author: Colin Walters <walters verbum org>
Date:   Mon Oct 17 15:55:06 2011 -0400

    src: Only use local VFS - this avoids hitting up the session bus
    
    We are designed to run in the "unix model" of being forked a lot, so
    startup time matters a lot, and hitting the session bus adds
    unnecessary DBus traffic, shows up in strace etc.
    
    It's a microoptimization I admit.

 src/ht-builtin-init.c           |    2 +-
 src/libhacktree/hacktree-repo.c |    4 ++--
 src/libhtutil/ht-gio-utils.c    |    7 +++++++
 src/libhtutil/ht-gio-utils.h    |    2 ++
 4 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/ht-builtin-init.c b/src/ht-builtin-init.c
index 6c22f4d..4dc2d7f 100644
--- a/src/ht-builtin-init.c
+++ b/src/ht-builtin-init.c
@@ -52,7 +52,7 @@ hacktree_builtin_init (int argc, char **argv, const char *prefix, GError **error
     repo_path = ".";
 
   htdir_path = g_build_filename (repo_path, HACKTREE_REPO_DIR, NULL);
-  htdir = g_file_new_for_path (htdir_path);
+  htdir = ht_util_new_file_for_path (htdir_path);
 
   if (!g_file_make_directory (htdir, NULL, error))
     goto out;
diff --git a/src/libhacktree/hacktree-repo.c b/src/libhacktree/hacktree-repo.c
index 6781d25..90b34ad 100644
--- a/src/libhacktree/hacktree-repo.c
+++ b/src/libhacktree/hacktree-repo.c
@@ -132,7 +132,7 @@ hacktree_repo_constructor (GType                  gtype,
 
   g_assert (priv->path != NULL);
   
-  priv->repo_file = g_file_new_for_path (priv->path);
+  priv->repo_file = ht_util_new_file_for_path (priv->path);
   priv->head_ref_path = g_build_filename (priv->path, HACKTREE_REPO_DIR, "HEAD", NULL);
   priv->objects_path = g_build_filename (priv->path, HACKTREE_REPO_DIR, "objects", NULL);
 
@@ -1534,7 +1534,7 @@ hacktree_repo_iter_objects (HacktreeRepo  *self,
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
   g_return_val_if_fail (priv->inited, FALSE);
 
-  objectdir = g_file_new_for_path (priv->objects_path);
+  objectdir = ht_util_new_file_for_path (priv->objects_path);
   enumerator = g_file_enumerate_children (objectdir, "standard::name,standard::type,unix::*", 
                                           G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
                                           NULL, 
diff --git a/src/libhtutil/ht-gio-utils.c b/src/libhtutil/ht-gio-utils.c
index 615699a..c49b883 100644
--- a/src/libhtutil/ht-gio-utils.c
+++ b/src/libhtutil/ht-gio-utils.c
@@ -105,3 +105,10 @@ ht_util_read_file_noatime (GFile *file, GCancellable *cancellable, GError **erro
   g_free (path);
   return ret;
 }
+
+/* Like g_file_new_for_path, but only do local stuff, not GVFS */
+GFile *
+ht_util_new_file_for_path (const char *path)
+{
+  return g_vfs_get_file_for_path (g_vfs_get_local (), path);
+}
diff --git a/src/libhtutil/ht-gio-utils.h b/src/libhtutil/ht-gio-utils.h
index 388a654..c7342c4 100644
--- a/src/libhtutil/ht-gio-utils.h
+++ b/src/libhtutil/ht-gio-utils.h
@@ -26,6 +26,8 @@
 
 G_BEGIN_DECLS
 
+GFile *ht_util_new_file_for_path (const char *path);
+
 gboolean ht_util_ensure_directory (const char *path, gboolean with_parents, GError **error);
 
 char * ht_util_get_file_contents_utf8 (const char *path, GError    **error);



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