[Monodevelop-patches-list] r2170 - in trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets: . Tree

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Wed Jan 26 18:54:32 EST 2005


Author: lluis
Date: 2005-01-26 18:54:31 -0500 (Wed, 26 Jan 2005)
New Revision: 2170

Modified:
   trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/ChangeLog
   trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Tree/TreeNodeCollection.cs
Log:
2005-01-27  Lluis Sanchez Gual  <lluis at novell.com>

	* Tree/TreeNodeCollection.cs: Save some memory.



Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/ChangeLog	2005-01-26 22:38:13 UTC (rev 2169)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/ChangeLog	2005-01-26 23:54:31 UTC (rev 2170)
@@ -1,3 +1,7 @@
+2005-01-27  Lluis Sanchez Gual  <lluis at novell.com>
+
+	* Tree/TreeNodeCollection.cs: Save some memory.
+
 2004-12-01  John Luke  <john.luke at gmail.com>
 
 	* FileBrowser/FileBrowser.cs: port to GtkAction

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Tree/TreeNodeCollection.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Tree/TreeNodeCollection.cs	2005-01-26 22:38:13 UTC (rev 2169)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Tree/TreeNodeCollection.cs	2005-01-26 23:54:31 UTC (rev 2170)
@@ -6,24 +6,22 @@
 namespace MonoDevelop.Gui.Widgets {
     public class TreeNodeCollection: IList {
 		private ArrayList list;
-                                                                                                                             
-		public TreeNodeCollection() {
-			list = new ArrayList();
-		}
 
 		public int Count {
-			get { return list.Count; }
+			get { return list != null ? list.Count : 0; }
 		}
 
 		public bool IsReadOnly {
-			get { return list.IsReadOnly; }
+			get { return false; }
 		}
 		
 		public virtual TreeNode this[int index] {
 			get {
+				if (list == null) throw new ArgumentOutOfRangeException( "index" );
 				return (TreeNode) list[index];
 			}
 			set {
+				if (list == null) list = new ArrayList ();
 				list[index] = value; //TODO
 				Changed();
 			}
@@ -31,12 +29,14 @@
 		
 		public void Sort ()
 		{
+			if (list == null) return;
 			list.Sort ();
 			Changed ();
 		}
 		
 		public void Sort (IComparer c)
 		{
+			if (list == null) return;
 			list.Sort (c);
 			Changed ();
 		}
@@ -53,6 +53,7 @@
 			if (node == null)
 				throw new ArgumentNullException("value");
 
+			if (list == null) list = new ArrayList ();
 			Inserted(node);
 			int index = list.Add(node);
 			return 	index;		
@@ -70,6 +71,7 @@
 
 		public virtual void Clear() 
 		{
+			if (list == null) return;
 			ArrayList tmp = (ArrayList)list.Clone();
 			foreach (TreeNode node in tmp) {
 				Remove(node);
@@ -78,6 +80,7 @@
 		
 		public bool Contains(TreeNode node) 
 		{
+			if (list == null) return false;
 			return list.Contains(node);
 		}
 
@@ -88,16 +91,20 @@
 
 		public IEnumerator GetEnumerator() 
 		{
+			if (list == null) return Type.EmptyTypes.GetEnumerator ();
 			return list.GetEnumerator();
 		}
 
 		public int IndexOf(TreeNode node) 
 		{
+			if (list == null) return -1;
 			return list.IndexOf(node);
 		}
 
 		public virtual void Insert(int index, TreeNode node) 
 		{
+			if (list == null) list = new ArrayList ();
+
 			if ( node == null )
 				throw new ArgumentNullException ( "node" );
 
@@ -112,13 +119,14 @@
 		{
 			if ( node == null )
 				throw new ArgumentNullException( "node" );
+			if (list == null) return;
 			Removed(node);
 			list.Remove(node);
 		}
 
 		public virtual void RemoveAt(int index) 
 		{
-			if (index < 0 || index > Count )
+			if (list == null || index < 0 || index > Count )
 				throw new ArgumentOutOfRangeException( "index" );
 
 			TreeNode node = (TreeNode) list[ index ];
@@ -139,6 +147,7 @@
 
 		object IList.this[int index]{
 			get{
+				if (list == null) throw new ArgumentOutOfRangeException( "index" );
 				return list[index];
 			}
 			set{
@@ -155,10 +164,12 @@
 		}
 
 		bool IList.Contains(object value){
+			if (list == null) return false;
 			return list.Contains(value);
 		}
 
 		int IList.IndexOf(object value){
+			if (list == null) return -1;
 			return list.IndexOf(value);
 		}
 




More information about the Monodevelop-patches-list mailing list