Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Maurer <benm@mono-cvs.ximian.com>2004-12-21 21:54:07 +0300
committerBen Maurer <benm@mono-cvs.ximian.com>2004-12-21 21:54:07 +0300
commit1e30148bfb4a992ca2e55c0c887594ae519609c3 (patch)
tree3701369b5a581a13f3ce3f43a0034afd878c34eb /mcs/class/corlib/System.Collections/Hashtable.cs
parent144375c222eaddbfc10603e8bffa4ad8aa73b42f (diff)
2004-12-21 Ben Maurer <bmaurer@ximian.com>
* Hashtable.cs (GetHash): Avoid a method call. Also, don't store the this.hcpRef in a variable. This will create another register which must be pushed on the stack. It is better to just reference the variable again. hcpRef.GetHashCode (key) is the slow path anyways, so an extra variable reference here doesn't hurt (KeyEquals): ditto. This gives me a few % back in a raw benchmark. svn path=/trunk/mcs/; revision=38044
Diffstat (limited to 'mcs/class/corlib/System.Collections/Hashtable.cs')
-rw-r--r--mcs/class/corlib/System.Collections/Hashtable.cs15
1 files changed, 7 insertions, 8 deletions
diff --git a/mcs/class/corlib/System.Collections/Hashtable.cs b/mcs/class/corlib/System.Collections/Hashtable.cs
index fb2631cab97..070f2e60a8f 100644
--- a/mcs/class/corlib/System.Collections/Hashtable.cs
+++ b/mcs/class/corlib/System.Collections/Hashtable.cs
@@ -504,10 +504,10 @@ namespace System.Collections {
/// <summary>Returns the hash code for the specified key.</summary>
protected virtual int GetHash (Object key)
{
- IHashCodeProvider hcp = this.hcp;
- return (hcp!= null)
- ? hcp.GetHashCode (key)
- : key.GetHashCode ();
+ if (hcpRef == null)
+ return key.GetHashCode ();
+
+ return hcpRef.GetHashCode (key);
}
/// <summary>
@@ -516,11 +516,10 @@ namespace System.Collections {
/// </summary>
protected virtual bool KeyEquals (Object item, Object key)
{
- IComparer c = this.comparer;
- if (c!= null)
- return (c.Compare (item, key) == 0);
- else
+ if (comparerRef == null)
return item.Equals (key);
+
+ return comparerRef.Compare (item, key) == 0;
}