dotgnu-pnet-commits
[Top][All Lists]
Advanced

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

[dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/Collections/Ar...


From: Heiko Weiss
Subject: [dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/Collections/Ar...
Date: Thu, 19 Oct 2006 12:25:25 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnetlib
Changes by:     Heiko Weiss <brubbel>   06/10/19 12:25:25

Modified files:
        .              : ChangeLog 
        runtime/System/Collections: ArrayList.cs 

Log message:
        ctor with ICollection and SetRange optimized

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnetlib/ChangeLog?cvsroot=dotgnu-pnet&r1=1.2443&r2=1.2444
http://cvs.savannah.gnu.org/viewcvs/pnetlib/runtime/System/Collections/ArrayList.cs?cvsroot=dotgnu-pnet&r1=1.22&r2=1.23

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/ChangeLog,v
retrieving revision 1.2443
retrieving revision 1.2444
diff -u -b -r1.2443 -r1.2444
--- ChangeLog   18 Oct 2006 10:13:53 -0000      1.2443
+++ ChangeLog   19 Oct 2006 12:25:25 -0000      1.2444
@@ -1,3 +1,8 @@
+2006-10-19  Heiko Weiss <address@hidden>
+
+       * runtime/System/Collections/ArrayList.cs: 
+       ctor with ICollection and SetRange optimized.
+
 2006-10-18  Heiko Weiss <address@hidden>
 
        * runtime/System/Collections/ArrayList.cs: fixed AddRange of self.

Index: runtime/System/Collections/ArrayList.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/runtime/System/Collections/ArrayList.cs,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- runtime/System/Collections/ArrayList.cs     18 Oct 2006 10:13:53 -0000      
1.22
+++ runtime/System/Collections/ArrayList.cs     19 Oct 2006 12:25:25 -0000      
1.23
@@ -53,36 +53,13 @@
        // Construct an array list from the contents of a collection.
        public ArrayList(ICollection c)
                        {
-                               IEnumerator enumerator;
-                               int index;
                                if(c == null)
                                {
                                        throw new ArgumentNullException("c");
                                }
-#if !ECMA_COMPAT
-                               Array chkArray = c as Array;
-                               if (chkArray != null)
-                               {
-                                       if(chkArray.Rank != 1)
-                                       {
-                                               throw new 
RankException(_("Arg_RankMustBe1"));
-                                       }
-                                       // now we can use this information to 
use Array.Copy
-                                       count = chkArray.Length;
-                                       store = new Object[count];
-                                       Array.Copy(chkArray, 0, store, 0, 
count);
-                                       generation = 0;
-                                       return;
-                               }
-#endif
-                               count = c.Count;
-                               store = new Object [count];
-                               enumerator = c.GetEnumerator();
-                               for(index = 0; enumerator.MoveNext(); ++index)
-                               {
-                                       store[index] = enumerator.Current;
-                               }
-                               generation = 0;
+                               count = 0;
+                               store = new Object[c.Count];
+                               this.InsertRange( count, c );
                        }
 
        // Reallocate the array to accomodate "n" new entries at "index".
@@ -661,29 +638,21 @@
        // Set a range of array list elements to the members of a collection.
        public virtual void SetRange(int index, ICollection c)
                        {
-                               int count;
-                               IEnumerator enumerator;
                                if(c == null)
                                {
                                        throw new ArgumentNullException("c");
                                }
-                               if(index < 0)
-                               {
+                               int cCount = c.Count;
+                               if( (index < 0) || (index > (this.count - 
cCount ) ) ) {
                                        throw new ArgumentOutOfRangeException
                                                ("index", _("ArgRange_Array"));
                                }
-                               count = c.Count;
-                               if((this.count - index) < count)
-                               {
-                                       throw new 
ArgumentOutOfRangeException(_("Arg_InvalidArrayRange"));
-                               }
-                               enumerator = c.GetEnumerator();
-                               while(enumerator.MoveNext())
-                               {
-                                       store[index++] = enumerator.Current;
-                               }
+                               
+                               if( cCount > 0 ) {
+                                       c.CopyTo( this.store, index );
                                ++generation;
                        }
+                       }
 
        // Inner version of "Sort".
        private void InnerSort(int lower, int upper, IComparer comparer)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]