[egg-list-box] Avoid updating separators while not visible



commit 09135fbb8f99d1c69d39069ed959959349bba43f
Author: Alexander Larsson <alexl redhat com>
Date:   Wed May 16 14:35:27 2012 +0200

    Avoid updating separators while not visible
    
    This helps avoiding an O(n^2) add() loop where all child widgets
    are non-visible during child addition, so we its quite expensive
    to find the previous visible child.

 egg-list-box.vala |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/egg-list-box.vala b/egg-list-box.vala
index 9b97374..f1893e2 100644
--- a/egg-list-box.vala
+++ b/egg-list-box.vala
@@ -135,9 +135,11 @@ public class Egg.ListBox : Container {
       this.queue_resize ();
     }
     apply_filter (info.widget);
-    update_separator (info.iter);
-    update_separator (get_next_visible (info.iter));
-    update_separator (prev_next);
+    if (this.get_visible ()) {
+      update_separator (info.iter);
+      update_separator (get_next_visible (info.iter));
+      update_separator (prev_next);
+    }
 
   }
 
@@ -432,6 +434,11 @@ public class Egg.ListBox : Container {
     return false;
   }
 
+  public override void show () {
+    reseparate ();
+    base.show ();
+  }
+
   public override bool focus (DirectionType direction) {
     bool had_focus;
     bool focus_into;
@@ -756,10 +763,12 @@ public class Egg.ListBox : Container {
 
     apply_filter (widget);
 
-    var prev_next = get_next_visible (iter);
-    update_separator (iter);
-    update_separator (get_next_visible (iter));
-    update_separator (prev_next);
+    if (this.get_visible ()) {
+      var prev_next = get_next_visible (iter);
+      update_separator (iter);
+      update_separator (get_next_visible (iter));
+      update_separator (prev_next);
+    }
 
     info.iter = iter;
 
@@ -790,7 +799,8 @@ public class Egg.ListBox : Container {
     child_hash.remove (widget);
     children.remove (info.iter);
 
-    update_separator (next);
+    if (this.get_visible ())
+      update_separator (next);
 
     if (was_visible && this.get_visible ())
       this.queue_resize ();



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