PATCH: #375548 Cache the result of nautilus_directory_is_local()



Hi,

While looking for a problem with slow SMB shares, I discovered that
Nautilus calls nautilus_file_is_local() -> nautilus_directory_is_local()
-> gnome_vfs_uri_is_local() a *lot*.  This leads to many roundtrips to
gnome-vfs-daemon for SMB URIs.

We can cache the result of gnome_vfs_is_local() inside
NautilusDirectory.  This gets rid of the roundtrips.

The bug is http://bugzilla.gnome.org/show_bug.cgi?id=375548

OK to commit?

  Federico

2006-11-14  Federico Mena Quintero  <federico novell com>

	nautilus_directory_is_local() gets called *really* often, mainly
	from nautilus_file_is_local().  So, we cache its result.  This
	drastically cuts down on the number of roundtrips to
	gnome-vfs-daemon for SMB directories.  Fixes
	http://bugzilla.gnome.org/show_bug.cgi?id=375548

	* libnautilus-private/nautilus-directory-private.h (struct
	NautilusDirectoryDetails): Added fields "is_local_known",
	"is_local".

	* libnautilus-private/nautilus-directory.c
	(nautilus_directory_is_local): Cache the result of
	gnome_vfs_uri_is_local() in directory->details->is_local.

--- nautilus-no-debug-log/libnautilus-private/nautilus-directory-private.h	2006-11-10 16:39:40.000000000 -0600
+++ nautilus-2.12.2/libnautilus-private/nautilus-directory-private.h	2006-11-14 15:54:34.000000000 -0600
@@ -46,6 +46,12 @@ struct NautilusDirectoryDetails
 	char *uri;
 	GnomeVFSURI *vfs_uri;
 
+	/* since nautilus_directory_is_local() is called so often (mainly from
+	 * NautilusFile), we cache its result.
+	 */
+	gboolean is_local_known;
+	gboolean is_local;
+
 	/* The file objects. */
 	NautilusFile *as_file;
 	GList *file_list;
--- nautilus-no-debug-log/libnautilus-private/nautilus-directory.c	2006-11-10 16:39:41.000000000 -0600
+++ nautilus-2.12.2/libnautilus-private/nautilus-directory.c	2006-11-14 15:57:59.000000000 -0600
@@ -542,7 +542,13 @@ nautilus_directory_is_local (NautilusDir
 	if (directory->details->vfs_uri == NULL) {
 		return TRUE;
 	}
-	return gnome_vfs_uri_is_local (directory->details->vfs_uri);
+
+	if (!directory->details->is_local_known) {
+		directory->details->is_local = gnome_vfs_uri_is_local (directory->details->vfs_uri);
+		directory->details->is_local_known = TRUE;
+	}
+
+	return directory->details->is_local;
 }
 
 gboolean


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