|
From: <pa...@us...> - 2011-01-13 01:12:41
|
Revision: 5344
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5344&view=rev
Author: patearl
Date: 2011-01-13 01:12:33 +0000 (Thu, 13 Jan 2011)
Log Message:
-----------
Use loop to compare binary arrays rather than enumerators for roughly 5x performance increase.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Type/AbstractBinaryType.cs
trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs
Modified: trunk/nhibernate/src/NHibernate/Type/AbstractBinaryType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/AbstractBinaryType.cs 2010-12-31 03:23:40 UTC (rev 5343)
+++ trunk/nhibernate/src/NHibernate/Type/AbstractBinaryType.cs 2011-01-13 01:12:33 UTC (rev 5344)
@@ -46,7 +46,7 @@
if (x == null || y == null)
return false;
- return CollectionHelper.CollectionEquals<byte>(ToInternalFormat(x), ToInternalFormat(y));
+ return ArrayHelper.ArrayEquals(ToInternalFormat(x), ToInternalFormat(y));
}
public IComparer Comparator
Modified: trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2010-12-31 03:23:40 UTC (rev 5343)
+++ trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2011-01-13 01:12:33 UTC (rev 5344)
@@ -378,5 +378,25 @@
return true;
}
+
+ public static bool ArrayEquals(byte[] a, byte[] b)
+ {
+ if (a.Length != b.Length)
+ {
+ return false;
+ }
+
+ int i = 0;
+ int len = a.Length;
+ while(i < len)
+ {
+ if (a[i] != b[i])
+ {
+ return false;
+ }
+ i++;
+ }
+ return true;
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|