gnome-commander r2126 - in branches/gcmd-1-3: . src



Author: epiotr
Date: Fri Sep 26 22:45:46 2008
New Revision: 2126
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2126&view=rev

Log:
Iterate through the file list MUCH faster (O(n*n) -> O(n))

Modified:
   branches/gcmd-1-3/ChangeLog
   branches/gcmd-1-3/src/gnome-cmd-delete-dialog.cc

Modified: branches/gcmd-1-3/src/gnome-cmd-delete-dialog.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-delete-dialog.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-delete-dialog.cc	Fri Sep 26 22:45:46 2008
@@ -159,21 +159,19 @@
 static void perform_delete_operation (DeleteData *data)
 {
     GList *uri_list = NULL;
-    gint num_files = g_list_length (data->files);
 
-    // Go through all files and add the uri of the appropriate ones to a list
-    for (gint i=0; i<num_files; i++)
+    // go through all files and add the uri of the appropriate ones to a list
+    for (GList *i=data->files; i; i=i->next)
     {
-        GnomeCmdFile *finfo = (GnomeCmdFile *) g_list_nth_data (data->files, i);
+        GnomeCmdFile *f = (GnomeCmdFile *) i->data;
 
-        if (strcmp(finfo->info->name, "..") == 0 || strcmp(finfo->info->name, ".") == 0)
+        if (strcmp(f->info->name, "..") == 0 || strcmp(f->info->name, ".") == 0)
             continue;
 
-        GnomeVFSURI *uri = gnome_cmd_file_get_uri (finfo);
+        GnomeVFSURI *uri = gnome_cmd_file_get_uri (f);
         if (!uri) continue;
 
-        gnome_vfs_uri_ref (uri);
-        uri_list = g_list_append (uri_list, uri);
+        uri_list = g_list_append (uri_list, gnome_vfs_uri_ref (uri));
     }
 
     if (uri_list)



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