[Mono-bugs] [Bug 70620][Wis] New - ArrayList constructor instantiates array twice

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 16 Dec 2004 17:25:48 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by info@terratek.biz.

http://bugzilla.ximian.com/show_bug.cgi?id=70620

--- shadow/70620	2004-12-16 17:25:48.000000000 -0500
+++ shadow/70620.tmp.27772	2004-12-16 17:25:48.000000000 -0500
@@ -0,0 +1,55 @@
+Bug#: 70620
+Product: Mono: Class Libraries
+Version: 1.0
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: info@terratek.biz               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: ArrayList constructor instantiates array twice
+
+Browsing through the ArrayList code (1.05), I found the following private 
+constructor:
+
+/// <summary>
+/// Initializes a new array list that contains a copy of the given array 
+and with the
+/// given count.
+/// </summary>
+/// <param name="array"></param>
+private ArrayList(object[] array, int index, int count) 
+{
+-->	_items = new object[count];
+
+	if (count == 0) 
+	{
+		_items = new object[DefaultInitialCapacity];
+	}
+	else 
+	{
+		_items = new object[count];
+	}
+
+	Array.Copy(array, index, _items, 0, count);
+
+	_size = count;
+}
+
+The marked line seems to be not necessary and inefficient if not dangerous 
+(I'm not sure how the Array instantiation responds to instantiation with 
+size 0)
+
+I would remove the line but I'm not setup and don't have the time right now 
+to go through the hoops of getting setup.
+
+Regards,
+
+Jens