浏览代码

* Hashtable.cs: Remove GetImpl and inline it.



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

Ben Maurer 21 年之前
父节点
当前提交
d12836d6ae
共有 2 个文件被更改,包括 12 次插入16 次删除
  1. 3 1
      mcs/class/corlib/System.Collections/ChangeLog
  2. 9 15
      mcs/class/corlib/System.Collections/Hashtable.cs

+ 3 - 1
mcs/class/corlib/System.Collections/ChangeLog

@@ -1,9 +1,11 @@
 2004-12-20  Ben Maurer  <[email protected]>
 
+	* 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.
 

+ 9 - 15
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);
 				}
 			}