[gitg] files: optimization to avoid o(n^2) iteration



commit 04249d8fbe63b6ea2e6a53ead6f567f681013dc1
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sat Feb 16 14:49:21 2013 +0100

    files: optimization to avoid o(n^2) iteration

 plugins/files/gitg-files-tree-store.vala |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/plugins/files/gitg-files-tree-store.vala b/plugins/files/gitg-files-tree-store.vala
index ef5a08a..fa0236f 100644
--- a/plugins/files/gitg-files-tree-store.vala
+++ b/plugins/files/gitg-files-tree-store.vala
@@ -167,20 +167,25 @@ public class TreeStore : Gtk.TreeStore
                        });
                } catch (Error e) { }
 
+               if (items == null)
+               {
+                       return;
+               }
+
                items.reverse();
 
+               unowned List<Item?>? i = items;
                var paths = new HashTable<string, Gtk.TreePath>(str_hash, str_equal);
-               var i = 0;
                d_update_id = Idle.add(() => {
-                       Item? item = items.nth_data(i);
-                       i++;
-
-                       if (item == null)
+                       if (i == null)
                        {
                                d_update_id = 0;
                                return false;
                        }
 
+                       Item item = i.data;
+                       i = i.next;
+
                        var root = item.root;
                        var entry = item.entry;
                        var isdir = entry.get_file_mode() == Ggit.FileMode.TREE;


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