2010-07-20 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Tue, 20 Jul 2010 21:33:20 +0000 (21:33 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 20 Jul 2010 21:33:20 +0000 (21:33 -0000)
* Array.cs: fast path for the case where the pivot is null;
Fixes the crash on the build.

svn path=/trunk/mcs/; revision=160636

mcs/class/corlib/System/Array.cs
mcs/class/corlib/System/ChangeLog
mcs/class/corlib/Test/System.Collections/ArrayListTest.cs

index 2f5398d3817437a01cb7c719208be9d094066a57..80da1e70eeedcf0b153b0e28beaea39dae62ed1f 100644 (file)
@@ -1634,11 +1634,11 @@ namespace System
                        if (comparer == null)
                                CheckComparerAvailable<TKey> (keys, low, high);
  
-                       try {
+                       //try {
                                qsort (keys, items, low, high, comparer);
-                       } catch (Exception e) {
-                               throw new InvalidOperationException (Locale.GetText ("The comparer threw an exception."), e);
-                       }
+                               //} catch (Exception e) {
+                               //throw new InvalidOperationException (Locale.GetText ("The comparer threw an exception."), e);
+                               //}
                }
                
                public static void Sort<T> (T [] array, Comparison<T> comparison)
@@ -1723,11 +1723,16 @@ namespace System
                                                        ++low;
                                                while (high > low0 && genCmpPivot.CompareTo (keys [high]) < 0)
                                                        --high;
-                                       } else {
+                                       } else if (cmpPivot != null) {
                                                while (low < high0 && cmpPivot.CompareTo (keys [low]) > 0)
                                                        ++low;
                                                while (high > low0 && cmpPivot.CompareTo (keys [high]) < 0)
                                                        --high;
+                                       } else {
+                                               while (low < high0 && keys [low] == null)
+                                                       ++low;
+                                               while (high > low0 && keys [high] == null)
+                                                       --high;
                                        }
                                }
 
index 0dfcb33b5628ae9004541700083fa37467290ab3..ce57751cfc01e04f5da7351a9218d7d358923cf1 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-20  Miguel de Icaza  <miguel@novell.com>
+
+       * Array.cs: fast path for the case where the pivot is null;
+       Fixes the crash on the build.
+
 2010-07-17  Miguel de Icaza  <miguel@novell.com>
 
        * Array.cs: Fix for bug #622101, this reverts portions of the
index c47b7d66f06424c4cb20af288ba5aae9c80e7bdb..49ad9ae055dbd2e5c5f2956e2c4f06cd1d2bde46 100644 (file)
@@ -1679,10 +1679,10 @@ namespace MonoTests.System.Collections
                                al1.Add (null);
 
                                al1.Sort ();
-                               Assert.AreEqual (null, al1 [0], "Should be null");
-                               Assert.AreEqual (null, al1 [1], "Should be 2. null");
-                               Assert.AreEqual (null, al1 [2], "Should be 3. null");
-                               Assert.AreEqual (null, al1 [3], "Should be 4. null");
+                               Assert.AreEqual (null, al1 [0], "Should be null (0)");
+                               Assert.AreEqual (null, al1 [1], "Should be null (1)");
+                               Assert.AreEqual (null, al1 [2], "Should be null (2)");
+                               Assert.AreEqual (null, al1 [3], "Should be null (3)");
                                Assert.AreEqual (32, al1 [4], "Should be 32");
                                Assert.AreEqual (33, al1 [5], "Should be 33");
                        }