Can the following function be improved in terms of performance?
I am calculating millions of such hashes. The long array represents a record from data table where all values are encoded as long values. Usually in one calculation stream all arrays are of the same length but in some rare cases this rule does not apply. Typical length of the array vary from 300 to 1 elements.
I was wondering whether using SIMD (SSE / AVX) instructions in System.Numerics.Vectors
library of .NET 4.6 could help?
public static int GetHashCode(long[] array)
{
if (array == null) return 0;
unchecked
{
int hash = 17;
for(int i = 0; i < array.Length; i++)
hash = 31 * hash + array[i].GetHashCode();
return hash;
}
}