Skip to content

Commit

Permalink
Thu Apr 11 12:28:13 CEST 2002 Paolo Molaro <lupus@ximian.com>
Browse files Browse the repository at this point in the history
	* String.cs: internalcall GetHashCode().
	* Array.cS: optimize access to elements.

svn path=/trunk/mcs/; revision=3758
  • Loading branch information
illupus committed Apr 11, 2002
1 parent e59897a commit eac9e57
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
32 changes: 16 additions & 16 deletions mcs/class/corlib/System/Array.cs
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
}

Expand Down
5 changes: 5 additions & 0 deletions mcs/class/corlib/System/ChangeLog
@@ -1,4 +1,9 @@

Thu Apr 11 12:28:13 CEST 2002 Paolo Molaro <lupus@ximian.com>

* String.cs: internalcall GetHashCode().
* Array.cS: optimize access to elements.

Wed Apr 10 21:20:19 CEST 2002 Paolo Molaro <lupus@ximian.com>

* String.cs: make IndexOfAny() use an internalcall.
Expand Down
10 changes: 2 additions & 8 deletions mcs/class/corlib/System/String.cs
Expand Up @@ -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 ()
{
Expand Down

0 comments on commit eac9e57

Please sign in to comment.