From d12836d6aebd0cd991fd505d96843bacb68e29cb Mon Sep 17 00:00:00 2001 From: Ben Maurer Date: Tue, 21 Dec 2004 00:22:57 +0000 Subject: [PATCH] * Hashtable.cs: Remove GetImpl and inline it. svn path=/trunk/mcs/; revision=38009 --- mcs/class/corlib/System.Collections/ChangeLog | 4 +++- mcs/class/corlib/System.Collections/Hashtable.cs | 24 +++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/mcs/class/corlib/System.Collections/ChangeLog b/mcs/class/corlib/System.Collections/ChangeLog index a2f2c104739..4776de06ddd 100644 --- a/mcs/class/corlib/System.Collections/ChangeLog +++ b/mcs/class/corlib/System.Collections/ChangeLog @@ -1,9 +1,11 @@ 2004-12-20 Ben Maurer + * Hashtable.cs: Remove GetImpl and inline it. + * Hashtable.cs (Find): Before calling KeyEquals, check to see if k == key (ie, they are the same pointer). In many cases, this will avoid two virtual calls. This gives me 1% on mcs bootstrap (!!!!) - + * Hashtable.cs (Find): Make `i' a uint rather than an int. This avoids having a long compare. diff --git a/mcs/class/corlib/System.Collections/Hashtable.cs b/mcs/class/corlib/System.Collections/Hashtable.cs index a1d60ccd361..8e1794bfb12 100644 --- a/mcs/class/corlib/System.Collections/Hashtable.cs +++ b/mcs/class/corlib/System.Collections/Hashtable.cs @@ -284,7 +284,12 @@ namespace System.Collections { public virtual Object this [Object key] { get { - return GetImpl (key); + int i = Find (key); + + if (i >= 0) + return table [i].value; + + return null; } set { PutImpl (key, value, true); @@ -542,17 +547,6 @@ namespace System.Collections { AdjustThreshold (); } - private Object GetImpl (Object key) - { - int i = Find (key); - - if (i >= 0) - return table [i].value; - else - return null; - } - - private int Find (Object key) { if (key == null) @@ -1042,11 +1036,11 @@ namespace System.Collections { public override Object this [Object key] { get { - return host.GetImpl (key); + return host [key]; } set { lock (host.SyncRoot) { - host.PutImpl (key, value, true); + host [key] = value; } } } @@ -1074,7 +1068,7 @@ namespace System.Collections { public override void Add (Object key, Object value) { lock (host.SyncRoot) { - host.PutImpl (key, value, false); + host.Add (key, value); } } -- 2.11.4.GIT