[banshee] [grid] Optimise ResizeChildCollection()



commit ffe03afd8717663628c8bb708bb932450822592a
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date:   Fri Mar 12 22:21:26 2010 +1100

    [grid] Optimise ResizeChildCollection()
    
    O(m) < O(nÃ?m)

 .../Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs
index 4072d34..d4d418e 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs
@@ -139,10 +139,10 @@ namespace Hyena.Data.Gui
         private void ResizeChildCollection (int newChildCount)
         {
             int difference = Children.Count - newChildCount;
-            while (Children.Count != newChildCount) {
-                if (difference > 0) {
-                    Children.RemoveAt (0);
-                } else {
+            if (difference > 0) {
+                Children.RemoveRange (newChildCount, difference);
+            } else {
+                for (int i=0; i>difference; i--) {
                     Children.Add (CreateChild ());
                 }
             }



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