[hyena] Optimise ResizeChildCollection()



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

    Optimise ResizeChildCollection()
    
    O(m) < O(nÃ?m)

 src/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs b/src/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs
index 4072d34..d4d418e 100644
--- a/src/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs
+++ b/src/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]