[Monodevelop-patches-list] r636 - in trunk/MonoDevelop/src/Main/Base: Gui/Pads/ClassScout Gui/Pads/ClassScout/NodeBuilder Internal/CollectionUtilities

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Sat Jan 24 20:20:49 EST 2004


Author: benm
Date: 2004-01-24 20:20:48 -0500 (Sat, 24 Jan 2004)
New Revision: 636

Modified:
   trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs
   trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/NodeBuilder/DefaultDotNetClassScoutNodeBuilder.cs
   trunk/MonoDevelop/src/Main/Base/Internal/CollectionUtilities/Comparers.cs
Log:
bring sorting to the class browser. we take a pretty big perf hit, we should look at this

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs	2004-01-25 01:01:07 UTC (rev 635)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs	2004-01-25 01:20:48 UTC (rev 636)
@@ -99,7 +99,7 @@
 			// TODO
 		}
 		
-		public ClassScout()
+		public ClassScout() : base (false, TreeNodeComparer.GtkDefault)
 		{
 			addParseInformationHandler = new ParseInformationEventHandler(OnParseInformationAdded);
 			removeParseInformationHandler = new ParseInformationEventHandler(OnParseInformationRemoved);
@@ -323,7 +323,7 @@
 					Populate(((CombineCombineEntry)entry).Combine, combineNode.Nodes);
 				}
 			}
-			SortUtility.QuickSort(combineNode.Nodes, TreeNodeComparer.Default);
+			
 			nodes.Add(combineNode);
 		}
 

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/NodeBuilder/DefaultDotNetClassScoutNodeBuilder.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/NodeBuilder/DefaultDotNetClassScoutNodeBuilder.cs	2004-01-25 01:01:07 UTC (rev 635)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/NodeBuilder/DefaultDotNetClassScoutNodeBuilder.cs	2004-01-25 01:20:48 UTC (rev 636)
@@ -59,14 +59,14 @@
 			
 			ICompilationUnit unit = (ICompilationUnit)e.ParseInformation.MostRecentCompilationUnit;
 			foreach (IClass c in unit.Classes) {
-				classNode.Text = c.Name;
-				//classNode.SelectedImageIndex = classNode.ImageIndex = classBrowserIconService.GetIcon(c);
-				classNode.Image = classBrowserIconService.ImageList[classBrowserIconService.GetIcon(c)];
+				// TODO: Perf check
 				TreeNode node = GetNodeByPath(c.Namespace, parentNode.Nodes, false);
 				if (node != null) {
-					int oldIndex = SortUtility.BinarySearch(classNode, node.Nodes, TreeNodeComparer.Default);
-					if(oldIndex >= 0) {
-						node.Nodes[oldIndex].Remove();
+					foreach (TreeNode nd in node.Nodes) {
+						if (nd.Text == c.Name) {
+							nd.Remove ();
+							return;
+						}
 					}
 				}
 			}
@@ -76,10 +76,8 @@
 		{
 			TreeNode newNode = BuildClassTreeNode((IProject)projectNode.Tag, imageIndexOffset);
 			projectNode.Nodes.Clear();
-			foreach (TreeNode node in newNode.Nodes) {
+			foreach (TreeNode node in newNode.Nodes)
 				projectNode.Nodes.Add(node);
-			}
-			SortUtility.QuickSort(projectNode.Nodes, TreeNodeComparer.Default);
 		}
 
 		public TreeNode BuildClassTreeNode(IProject p, int imageIndexOffset)
@@ -139,7 +137,8 @@
 				
 				TreeNode classNode = BuildClassNode(filename, c);
 				if(classNode != null) {
-					SortUtility.SortedInsert(classNode, node.Nodes, TreeNodeComparer.Default);
+					node.Nodes.Add (classNode);
+					
 					if (wasExpanded) {
 						classNode.Expand();
 					}
@@ -209,7 +208,6 @@
 				classNode.Nodes.Add(eventNode);
 			}
 			
-			SortUtility.QuickSort(classNode.Nodes, TreeNodeComparer.Default);
 			return classNode;
 		}
 		
@@ -232,7 +230,7 @@
 						//newnode.ImageIndex = newnode.SelectedImageIndex = classBrowserIconService.NamespaceIndex;
 						newnode.Image = classBrowserIconService.ImageList[classBrowserIconService.NamespaceIndex];
 
-						SortUtility.SortedInsert(newnode, curcollection, TreeNodeComparer.Default);
+						curcollection.Add (newnode);
 						curnode = newnode;
 						curcollection = curnode.Nodes;
 						continue;

Modified: trunk/MonoDevelop/src/Main/Base/Internal/CollectionUtilities/Comparers.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Internal/CollectionUtilities/Comparers.cs	2004-01-25 01:01:07 UTC (rev 635)
+++ trunk/MonoDevelop/src/Main/Base/Internal/CollectionUtilities/Comparers.cs	2004-01-25 01:20:48 UTC (rev 636)
@@ -107,6 +107,7 @@
 		public static IComparer Default    = new TreeNodeComparer();
 		public static IComparer ProjectNode = new ProjectNodeComparer();
 		public static Gtk.TreeIterCompareFunc GtkProjectNode = new Gtk.TreeIterCompareFunc (GtkProjectNodeComparer);
+		public static Gtk.TreeIterCompareFunc GtkDefault = new Gtk.TreeIterCompareFunc (GtkDefaultComparer);
 			
 		static int GtkProjectNodeComparer (Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b)
 		{
@@ -133,6 +134,15 @@
 			return x.Text.CompareTo(y.Text);
 		}
 		
+		static int GtkDefaultComparer (Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b)
+		{
+			Gtk.TreeStore ts = (Gtk.TreeStore) model;
+			TreeNode x = (TreeNode) ts.GetValue (a, 2);
+			TreeNode y = (TreeNode) ts.GetValue (b, 2);
+			
+			return x.Text.CompareTo (y.Text);
+		}
+		
 		protected TreeNodeComparer() {}
 		
 		public int Compare(TreeNode x, TreeNode y) {




More information about the Monodevelop-patches-list mailing list