[banshee/stable-1.6] [ColumnController] Reduce config accesses



commit e9e7a9017c9f09f88ede3eddef972019e05d6732
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Mon Apr 26 16:51:03 2010 -0700

    [ColumnController] Reduce config accesses
    
    We were getting config variables (eg from GConf) within a Sort function,
    so each one was called multiple times; instead load the values ahead of
    time just once.  In my testing, got rid of 300 extraneous GConf gets.

 .../PersistentColumnController.cs                  |   17 ++++++-----------
 .../Hyena/Hyena.Data/ColumnDescription.cs          |    2 ++
 2 files changed, 8 insertions(+), 11 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs
index 2f7641e..6d3fdba 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs
@@ -86,25 +86,20 @@ namespace Banshee.Collection.Gui
 
                 loaded = false;
 
+                int i = 0;
                 foreach (Column column in this) {
                     if (column.Id != null) {
                         string @namespace = MakeNamespace (column.Id);
                         column.Visible = ConfigurationClient.Get<bool> (@namespace, "visible", column.Visible);
                         column.Width = ConfigurationClient.Get<double> (@namespace, "width", column.Width);
+                        column.OrderHint = ConfigurationClient.Get<int> (@namespace, "order", i);
+                    } else {
+                        column.OrderHint = -1;
                     }
+                    i++;
                 }
 
-                // Create a copy so we can read the original index
-                List<Column> columns = new List<Column> (Columns);
-
-                Columns.Sort (delegate (Column a, Column b) {
-                    int a_order = a.Id == null ? -1 : ConfigurationClient.Get<int> (
-                        MakeNamespace (a.Id), "order", columns.IndexOf (a));
-                    int b_order = b.Id == null ? -1 : ConfigurationClient.Get<int> (
-                        MakeNamespace (b.Id), "order", columns.IndexOf (b));
-
-                    return a_order.CompareTo (b_order);
-                });
+                Columns.Sort ((a, b) => a.OrderHint.CompareTo (b.OrderHint));
 
                 string sort_ns = String.Format ("{0}.{1}.{2}", root_namespace, unique_source_id, "sort");
                 string sort_column_id = ConfigurationClient.Get<string> (sort_ns, "column", null);
diff --git a/src/Libraries/Hyena/Hyena.Data/ColumnDescription.cs b/src/Libraries/Hyena/Hyena.Data/ColumnDescription.cs
index cdb6a12..5ddbb98 100644
--- a/src/Libraries/Hyena/Hyena.Data/ColumnDescription.cs
+++ b/src/Libraries/Hyena/Hyena.Data/ColumnDescription.cs
@@ -99,6 +99,8 @@ namespace Hyena.Data
             }
         }
 
+        public int OrderHint { get; set; }
+
         public string Property {
             get { return property; }
             set { property = value; }



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