From eac9e5725a687f32b754ef9afb1ed43664bc000b Mon Sep 17 00:00:00 2001 From: Paolo Molaro Date: Thu, 11 Apr 2002 06:40:15 +0000 Subject: [PATCH] Thu Apr 11 12:28:13 CEST 2002 Paolo Molaro * String.cs: internalcall GetHashCode(). * Array.cS: optimize access to elements. svn path=/trunk/mcs/; revision=3758 --- mcs/class/corlib/System/Array.cs | 32 +++++++++++++++---------------- mcs/class/corlib/System/ChangeLog | 5 +++++ mcs/class/corlib/System/String.cs | 10 ++-------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/mcs/class/corlib/System/Array.cs b/mcs/class/corlib/System/Array.cs index 982617ae73269..52a32217665bb 100644 --- a/mcs/class/corlib/System/Array.cs +++ b/mcs/class/corlib/System/Array.cs @@ -405,7 +405,7 @@ public static int BinarySearch (Array array, int index, int length, object value while (iMin < iMax) { int iMid = (iMin + iMax) / 2; - object elt = array.GetValue (iMid); + object elt = array.GetValueImpl (iMid); // this order is from MSDN if (comparer != null) @@ -452,7 +452,7 @@ public static void Clear (Array array, int index, int length) for (int i = 0; i < length; i++) { - array.SetValue(null, index + i); + array.SetValueImpl(null, index + i); } } @@ -575,7 +575,7 @@ public static int IndexOf (Array array, object value, int index, int length) for (int i = 0; i < length; i++) { - if (array.GetValue(index + i).Equals(value)) + if (array.GetValueImpl(index + i).Equals(value)) return index + i; } @@ -612,7 +612,7 @@ public static int LastIndexOf (Array array, object value, int index, int length) for (int i = index; i >= index-length+1; i--) { - if (array.GetValue(i).Equals(value)) + if (array.GetValueImpl(i).Equals(value)) return i; } @@ -645,9 +645,9 @@ public static void Reverse (Array array, int index, int length) { object tmp; - tmp = array.GetValue (index + i); - array.SetValue(array.GetValue (index + length - i - 1), index + i); - array.SetValue(tmp, index + length - i - 1); + tmp = array.GetValueImpl (index + i); + array.SetValueImpl(array.GetValueImpl (index + length - i - 1), index + i); + array.SetValueImpl(tmp, index + length - i - 1); } } @@ -720,14 +720,14 @@ private static void qsort (Array keys, Array items, int low0, int high0, ICompar int low = low0; int high = high0; - object objPivot = keys.GetValue ((low + high) / 2); + object objPivot = keys.GetValueImpl ((low + high) / 2); while (low <= high) { // Move the walls in - while (low < high0 && compare (keys.GetValue (low), objPivot, comparer) < 0) + while (low < high0 && compare (keys.GetValueImpl (low), objPivot, comparer) < 0) ++low; - while (high > low0 && compare (objPivot, keys.GetValue (high), comparer) < 0) + while (high > low0 && compare (objPivot, keys.GetValueImpl (high), comparer) < 0) --high; if (low <= high) @@ -748,15 +748,15 @@ private static void swap (Array keys, Array items, int i, int j) { object tmp; - tmp = keys.GetValue (i); - keys.SetValue (keys.GetValue (j), i); - keys.SetValue (tmp, j); + tmp = keys.GetValueImpl (i); + keys.SetValueImpl (keys.GetValue (j), i); + keys.SetValueImpl (tmp, j); if (items != null) { - tmp = items.GetValue (i); - items.SetValue (items.GetValue (j), i); - items.SetValue (tmp, j); + tmp = items.GetValueImpl (i); + items.SetValueImpl (items.GetValueImpl (j), i); + items.SetValueImpl (tmp, j); } } diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog index 51c45bdfbd816..ffb8f77987fd5 100644 --- a/mcs/class/corlib/System/ChangeLog +++ b/mcs/class/corlib/System/ChangeLog @@ -1,4 +1,9 @@ +Thu Apr 11 12:28:13 CEST 2002 Paolo Molaro + + * String.cs: internalcall GetHashCode(). + * Array.cS: optimize access to elements. + Wed Apr 10 21:20:19 CEST 2002 Paolo Molaro * String.cs: make IndexOfAny() use an internalcall. diff --git a/mcs/class/corlib/System/String.cs b/mcs/class/corlib/System/String.cs index 5eeb7016763ab..450f197fbff9d 100644 --- a/mcs/class/corlib/System/String.cs +++ b/mcs/class/corlib/System/String.cs @@ -764,14 +764,8 @@ IEnumerator IEnumerable.GetEnumerator () return new CharEnumerator (this); } - public override int GetHashCode () - { - int h = 0; - int i; - for (i = 0; i < length; ++i) - h = (h << 5) - h + c_str [i]; - return h; - } + [MethodImplAttribute(MethodImplOptions.InternalCall)] + public extern override int GetHashCode (); public TypeCode GetTypeCode () {