Speeding up VFS - no more mc_stat("..")

Pavel Roskin proski at gnu.org
Sun Jan 20 20:05:12 UTC 2002


Hello!

That's the second part of the patch that speeds up VFS.  If there is no 
".." in the directory list, then a fake ".." is added.  However, mc will 
no longer go up the hierarchy to find the size of the ".." directory.

So, it you have an account of a system foo and your home directory is bar, 
then going to /#sh:foo/home/bar/subdir won't cause mc to get the listing 
of all users under /home.

============================
--- ChangeLog
+++ ChangeLog
@@ -2,2 +2,5 @@
 
+	* dir.c (add_dotdot_to_list): Don't use costly stat() - just put
+	realistic (i.e. bogus) data to the list.
+
 	* screen.c (string_file_size): Don't display size of ".." - it
--- dir.c
+++ dir.c
@@ -342,10 +342,6 @@ clean_dir (dir_list *list, int count)
 static int
 add_dotdot_to_list (dir_list *list, int index)
 {
-    char buffer [MC_MAXPATHLEN + MC_MAXPATHLEN];
-    char *p;
-    int i = 0;
-
     /* Need to grow the *list? */
     if (index == list->size) {
 	list->list = g_realloc (list->list, sizeof (file_entry) *
@@ -355,40 +351,14 @@ add_dotdot_to_list (dir_list *list, int 
 	list->size += RESIZE_STEPS;
     }
 
+    memset (&(list->list) [index], 0, sizeof(file_entry));
     (list->list) [index].fnamelen = 2;
     (list->list) [index].fname = g_strdup ("..");
     (list->list) [index].f.link_to_dir = 0;
     (list->list) [index].f.stalled_link = 0;
     (list->list) [index].f.dir_size_computed = 0;
-
-    /* FIXME: We need to get the panel definition! to use file_mark */
     (list->list) [index].f.marked = 0;
-    mc_get_current_wd (buffer, sizeof (buffer) - 1 );
-    if (buffer [strlen (buffer) - 1] == PATH_SEP)
-    	buffer [strlen (buffer) - 1] = 0;
-    for (;;) {
-    	strcat (buffer, PATH_SEP_STR "..");
-        p = vfs_canon (buffer);
-        if (mc_stat (p, &((list->list) [index].buf)) != -1){
-	    g_free (p);
-            break;
-	}
-        i = 1;
-        if (!strcmp (p, PATH_SEP_STR)){
-	    g_free (p);
-            return 1;
-	}
-	strcpy (buffer, p);
-	g_free (p);
-    }
-
-/* Commented out to preserve a usable '..'. What's the purpose of this
- * three lines? (Norbert) */
-#if 0
-    if (i) { /* So there is bogus information on the .. directory's stat */
-        (list->list) [index].buf.st_mode &= ~0444;
-    }
-#endif
+    (list->list) [index].buf.st_mode = 040755;
     return 1;
 }
 
============================

-- 
Regards,
Pavel Roskin




More information about the mc-devel mailing list