Perfomance optimization

This commit is contained in:
Melnik Alexander 2018-09-27 20:57:27 +03:00
parent 8a489d5a37
commit 027f8e12ed
2 changed files with 7 additions and 0 deletions

View File

@ -3,10 +3,12 @@
using System; using System;
using System.Buffers; using System.Buffers;
using System.IO; using System.IO;
using System.Runtime.CompilerServices;
using System.Threading.Tasks; using System.Threading.Tasks;
public static partial class xxHash32 public static partial class xxHash32
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe void Shift(byte[] data, int l, ref uint v1, ref uint v2, ref uint v3, ref uint v4) private static unsafe void Shift(byte[] data, int l, ref uint v1, ref uint v2, ref uint v3, ref uint v4)
{ {
fixed (byte* pData = &data[0]) fixed (byte* pData = &data[0])
@ -40,6 +42,7 @@
} }
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe uint Final(byte[] data, int l, ref uint v1, ref uint v2, ref uint v3, ref uint v4, long length, uint seed) private static unsafe uint Final(byte[] data, int l, ref uint v1, ref uint v2, ref uint v3, ref uint v4, long length, uint seed)
{ {
fixed (byte* pData = &data[0]) fixed (byte* pData = &data[0])
@ -87,6 +90,7 @@
return h32; return h32;
} }
} }
/// <summary> /// <summary>
/// Compute xxHash for the stream /// Compute xxHash for the stream

View File

@ -3,11 +3,13 @@
using System; using System;
using System.Buffers; using System.Buffers;
using System.IO; using System.IO;
using System.Runtime.CompilerServices;
using System.Threading.Tasks; using System.Threading.Tasks;
public static partial class xxHash64 public static partial class xxHash64
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe void Shift(byte[] data, int l, ref ulong v1, ref ulong v2, ref ulong v3, ref ulong v4) private static unsafe void Shift(byte[] data, int l, ref ulong v1, ref ulong v2, ref ulong v3, ref ulong v4)
{ {
fixed (byte* pData = &data[0]) fixed (byte* pData = &data[0])
@ -41,6 +43,7 @@
} }
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe ulong Final(byte[] data, int l, ref ulong v1, ref ulong v2, ref ulong v3, ref ulong v4, long length, ulong seed) private static unsafe ulong Final(byte[] data, int l, ref ulong v1, ref ulong v2, ref ulong v3, ref ulong v4, long length, ulong seed)
{ {
fixed (byte* pData = &data[0]) fixed (byte* pData = &data[0])