From 027f8e12edb72647b3fba72796b26f8ede063b1a Mon Sep 17 00:00:00 2001 From: Melnik Alexander Date: Thu, 27 Sep 2018 20:57:27 +0300 Subject: [PATCH] Perfomance optimization --- src/Standart.Hash.xxHash/xxHash32.Stream.cs | 4 ++++ src/Standart.Hash.xxHash/xxHash64.Stream.cs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/Standart.Hash.xxHash/xxHash32.Stream.cs b/src/Standart.Hash.xxHash/xxHash32.Stream.cs index af31af1..ae2a85a 100644 --- a/src/Standart.Hash.xxHash/xxHash32.Stream.cs +++ b/src/Standart.Hash.xxHash/xxHash32.Stream.cs @@ -3,10 +3,12 @@ using System; using System.Buffers; using System.IO; + using System.Runtime.CompilerServices; using System.Threading.Tasks; 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) { 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) { fixed (byte* pData = &data[0]) @@ -87,6 +90,7 @@ return h32; } } + /// /// Compute xxHash for the stream diff --git a/src/Standart.Hash.xxHash/xxHash64.Stream.cs b/src/Standart.Hash.xxHash/xxHash64.Stream.cs index fc1adad..4a25209 100644 --- a/src/Standart.Hash.xxHash/xxHash64.Stream.cs +++ b/src/Standart.Hash.xxHash/xxHash64.Stream.cs @@ -3,11 +3,13 @@ using System; using System.Buffers; using System.IO; + using System.Runtime.CompilerServices; using System.Threading.Tasks; 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) { 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) { fixed (byte* pData = &data[0])