Author: rgrabowski
Date: Thu Sep 28 16:52:46 2006
New Revision: 451063
URL: http://svn.apache.org/viewvc?view=rev&rev=451063
Log:
Cache MethodInfo for calls to System.Object.GetHashCode()
Modified:
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/HashCodeProvider.cs
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/HashCodeProvider.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/HashCodeProvider.cs?view=diff&rev=451063&r1=451062&r2=451063
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/HashCodeProvider.cs
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/HashCodeProvider.cs Thu
Sep 28 16:52:46 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -30,11 +30,21 @@
namespace IBatisNet.Common.Utilities
{
+ using System.Reflection;
+
/// <summary>
/// Summary description for HashCodeProvider.
/// </summary>
public class HashCodeProvider
{
+ private static MethodInfo getHashCodeMethodInfo = null;
+
+ static HashCodeProvider()
+ {
+ Type type = typeof(object);
+ getHashCodeMethodInfo = type.GetMethod("GetHashCode");
+ }
+
/// <summary>
/// Supplies a hash code for an object.
/// </summary>
@@ -48,11 +58,8 @@
/// </remarks>
public static int GetIdentityHashCode(object obj)
{
- System.Reflection.MethodInfo methodInfo = null;
- Type type = typeof(object);
-
- methodInfo = type.GetMethod("GetHashCode");
- return (int) methodInfo.Invoke(obj, null);
+ // call the underlying System.Object.GetHashCode()
+ return (int)getHashCodeMethodInfo.Invoke(obj, null);
}
}
}