Updating dependencies and removed my own Murmur3.cs implementation in favor of XXHash [skip ci]

This commit is contained in:
Robin Krom 2021-01-08 01:26:51 +01:00
commit 37b596d236
18 changed files with 27 additions and 248 deletions

View file

@ -24,6 +24,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapplo.Confluence" Version="1.0.16" /> <PackageReference Include="Dapplo.Confluence" Version="1.0.19" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -19,6 +19,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CliWrap" Version="3.2.3" /> <PackageReference Include="CliWrap" Version="3.3.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -23,6 +23,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MahApps.Metro" Version="2.3.4" /> <PackageReference Include="MahApps.Metro" Version="2.4.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapplo.Windows.Com" Version="0.11.17" /> <PackageReference Include="Dapplo.Windows.Com" Version="0.11.24" />
<PackageReference Include="Unofficial.Microsoft.mshtml" Version="7.0.3300" /> <PackageReference Include="Unofficial.Microsoft.mshtml" Version="7.0.3300" />
</ItemGroup> </ItemGroup>

View file

@ -20,8 +20,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapplo.Jira" Version="1.1.4" /> <PackageReference Include="Dapplo.Jira" Version="1.1.38" />
<PackageReference Include="Dapplo.Jira.SvgWinForms" Version="1.1.4" /> <PackageReference Include="Dapplo.Jira.SvgWinForms" Version="1.1.38" />
<PackageReference Include="DynamicData" Version="6.17.14" /> <PackageReference Include="DynamicData" Version="7.1.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -206,7 +206,7 @@ namespace Greenshot.Addon.Jira
{ {
try try
{ {
return await _jiraClient.Issue.GetAsync(issueKey, cancellationToken).ConfigureAwait(false); return await _jiraClient.Issue.GetAsync(issueKey, null, null, cancellationToken).ConfigureAwait(false);
} }
catch catch
{ {

View file

@ -23,6 +23,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MahApps.Metro" Version="2.3.4" /> <PackageReference Include="MahApps.Metro" Version="2.4.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -22,6 +22,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MahApps.Metro" Version="2.3.4" /> <PackageReference Include="MahApps.Metro" Version="2.4.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -20,12 +20,12 @@
<PackageReference Include="Dapplo.CaliburnMicro.Metro" Version="2.1.10" /> <PackageReference Include="Dapplo.CaliburnMicro.Metro" Version="2.1.10" />
<PackageReference Include="Dapplo.CaliburnMicro.Toasts" Version="2.1.10" /> <PackageReference Include="Dapplo.CaliburnMicro.Toasts" Version="2.1.10" />
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="2.1.10" /> <PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="2.1.10" />
<PackageReference Include="Dapplo.HttpExtensions" Version="1.0.3" /> <PackageReference Include="Dapplo.HttpExtensions" Version="1.0.8" />
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="1.0.3" /> <PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="1.0.8" />
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="1.0.3" /> <PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="1.0.8" />
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.11.17" /> <PackageReference Include="Dapplo.Windows.Clipboard" Version="0.11.24" />
<PackageReference Include="Dapplo.Windows.Dpi" Version="0.11.17" /> <PackageReference Include="Dapplo.Windows.Dpi" Version="0.11.24" />
<PackageReference Include="Dapplo.Windows.Icons" Version="0.11.17" /> <PackageReference Include="Dapplo.Windows.Icons" Version="0.11.24" />
<PackageReference Include="gong-wpf-dragdrop" Version="2.3.2" /> <PackageReference Include="gong-wpf-dragdrop" Version="2.3.2" />
<PackageReference Include="MahApps.Metro.IconPacks" Version="4.8.0" /> <PackageReference Include="MahApps.Metro.IconPacks" Version="4.8.0" />
<PackageReference Include="Svg" Version="3.1.1" /> <PackageReference Include="Svg" Version="3.1.1" />

View file

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapplo.Windows.Icons" Version="0.11.17" /> <PackageReference Include="Dapplo.Windows.Icons" Version="0.11.24" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -22,6 +22,7 @@ using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using Dapplo.Windows.Common.Extensions; using Dapplo.Windows.Common.Extensions;
using Dapplo.Windows.Common.Structs; using Dapplo.Windows.Common.Structs;
using HashDepot;
namespace Greenshot.Gfx.FastBitmap namespace Greenshot.Gfx.FastBitmap
{ {
@ -336,8 +337,8 @@ namespace Greenshot.Gfx.FastBitmap
{ {
var offset = (left ?? Left) * BytesPerPixel + y * Stride; var offset = (left ?? Left) * BytesPerPixel + y * Stride;
var length = (right ?? Right) - (left ?? Left) * BytesPerPixel; var length = (right ?? Right) - (left ?? Left) * BytesPerPixel;
var hash = new Murmur3(Seed); var values = new ReadOnlySpan<byte>(Pointer + offset, length);
return hash.CalculateHash(Pointer, offset, length); return XXHash.Hash32(values, Seed);
} }
/// <summary> /// <summary>

View file

@ -8,7 +8,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapplo.Addons" Version="1.3.3" /> <PackageReference Include="Dapplo.Addons" Version="1.3.3" />
<PackageReference Include="Dapplo.Log" Version="1.4.1" /> <PackageReference Include="Dapplo.Log" Version="1.4.1" />
<PackageReference Include="Dapplo.Windows.Dpi" Version="0.11.17" /> <PackageReference Include="Dapplo.Windows.Dpi" Version="0.11.24" />
<PackageReference Include="HashDepot" Version="2.0.3" />
<PackageReference Include="Svg" Version="3.1.1" /> <PackageReference Include="Svg" Version="3.1.1" />
<PackageReference Include="System.Memory" Version="4.5.4" /> <PackageReference Include="System.Memory" Version="4.5.4" />
</ItemGroup> </ItemGroup>

View file

@ -1,136 +0,0 @@
// Greenshot - a free and open source screenshot tool
// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
//
// For more information see: http://getgreenshot.org/
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 1 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Greenshot.Gfx
{
/// <summary>
/// This is an implementation of the Murmur3 hash algorithm
/// See <a href="https://en.wikipedia.org/wiki/MurmurHash">MurmurHash</a>
/// </summary>
public sealed class Murmur3
{
private const uint C1 = 0xcc9e2d51;
private const uint C2 = 0x1b873593;
private const int R1 = 15;
private const int R2 = 13;
private const uint M = 5;
private const uint N = 0xe6546b64;
private readonly uint _seed;
/// <summary>
/// Constructor for the Murmur3 algorithm
/// </summary>
/// <param name="seed"></param>
public Murmur3(uint seed)
{
_seed = seed;
}
/// <summary>
/// Wrapper for byte*
/// </summary>
/// <returns>uint</returns>
public unsafe uint CalculateHash(byte* pointer, int offset, int length)
{
var values = new ReadOnlySpan<byte>(pointer+offset, length);
return CalculateHash(values);
}
/// <summary>
/// Wrapper for string etc
/// </summary>
/// <typeparam name="TSpan">Type for the span</typeparam>
/// <param name="valuesToHash">ReadOnlySpan of TSpan</param>
/// <returns>uint</returns>
public uint CalculateHash<TSpan>(ReadOnlySpan<TSpan> valuesToHash) where TSpan : struct
{
return CalculateHash(MemoryMarshal.Cast<TSpan, byte>(valuesToHash));
}
/// <summary>
/// Calculate a Murmur3 hash for the specified values
/// </summary>
/// <param name="valuesToHash">ReadOnlySpan of byte</param>
/// <returns>uint with the hash</returns>
public uint CalculateHash(ReadOnlySpan<byte> valuesToHash)
{
var uintSpan = MemoryMarshal.Cast<byte, uint>(valuesToHash);
uint hash = _seed;
var uintSpanLength = uintSpan.Length;
// Hash with uints
for (int index = 0; index < uintSpanLength; index++)
{
var k = uintSpan[index];
unchecked
{
k *= C1;
k = RotateLeft(k, R1);
k *= C2;
hash ^= k;
hash = RotateLeft(hash, R2);
hash = hash * M + N;
}
}
int valuesToProcess = valuesToHash.Length - (uintSpanLength * 4);
if (valuesToProcess > 0)
{
uint k = 0;
var startingOffset = uintSpanLength * 4;
// Hash the rest
for (int index = 0; index < valuesToProcess; index++)
{
k |= (uint)valuesToHash[startingOffset + index] << (8 * index);
}
unchecked
{
k *= C1;
k = RotateLeft(k, R1);
k *= C2;
hash ^= k;
}
}
// Calculate the final hash
hash ^= (uint)valuesToHash.Length;
unchecked
{
hash ^= hash >> 16;
hash *= 0x85ebca6b;
hash ^= hash >> 13;
hash *= 0xc2b2ae35;
hash ^= hash >> 16;
}
return hash;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint RotateLeft(uint x, byte r)
{
return (x << r) | (x >> (32 - r));
}
}
}

View file

@ -1,41 +0,0 @@
// Greenshot - a free and open source screenshot tool
// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
//
// For more information see: http://getgreenshot.org/
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 1 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using BenchmarkDotNet.Attributes;
using Greenshot.Gfx;
namespace Greenshot.PerformanceTests
{
/// <summary>
/// This defines the benchmarks which can be done
/// </summary>
[MinColumn, MaxColumn, MemoryDiagnoser]
public class Murmur3Performance
{
private static readonly string TestString = "The quick brown fox jumps over the lazy dog";
[Benchmark]
public void MurmurPerformanceTest()
{
var hashAlgorithm = new Murmur3(0x9747b28c);
hashAlgorithm.CalculateHash(TestString.AsSpan());
}
}
}

View file

@ -30,7 +30,6 @@ namespace Greenshot.PerformanceTests
// ReSharper disable once UnusedParameter.Local // ReSharper disable once UnusedParameter.Local
private static void Main(string[] args) private static void Main(string[] args)
{ {
//BenchmarkRunner.Run<Murmur3Performance>();
BenchmarkRunner.Run<GfxPerformance>(); BenchmarkRunner.Run<GfxPerformance>();
//BenchmarkRunner.Run<CapturePerformance>(); //BenchmarkRunner.Run<CapturePerformance>();
Console.ReadLine(); Console.ReadLine();

View file

@ -31,8 +31,8 @@
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" /> <PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="CommandLineParser" Version="2.8.0" /> <PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Dapplo.Log.XUnit" Version="1.4.1" /> <PackageReference Include="Dapplo.Log.XUnit" Version="1.4.1" />
<PackageReference Include="Dapplo.Windows" Version="0.11.17" /> <PackageReference Include="Dapplo.Windows" Version="0.11.24" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" /> <PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.analyzers" Version="0.10.0" /> <PackageReference Include="xunit.analyzers" Version="0.10.0" />

View file

@ -1,45 +0,0 @@
// Greenshot - a free and open source screenshot tool
// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
//
// For more information see: http://getgreenshot.org/
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 1 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Text;
using Greenshot.Gfx;
using Greenshot.Tests.Extensions;
using Xunit;
namespace Greenshot.Tests
{
/// <summary>
/// Some simple tests to prove Murmur3 was correctly implemented
/// </summary>
public class Murmur3Tests
{
private static readonly uint Seed = 0x9747b28c;
private static readonly string TestString = "The quick brown fox jumps over the lazy dog";
[Fact]
public void Murmur3_Test()
{
var murmur3Span = new Murmur3(Seed);
var testBytes = Encoding.UTF8.GetBytes(TestString);
var hash = murmur3Span.CalculateHash(testBytes.AsSpan());
Assert.Equal(0x2FA826CDu, hash);
}
}
}

View file

@ -38,12 +38,12 @@
<PackageReference Include="Dapplo.CaliburnMicro.Dapp" Version="2.1.10" /> <PackageReference Include="Dapplo.CaliburnMicro.Dapp" Version="2.1.10" />
<PackageReference Include="Dapplo.Log.LogFile" Version="1.4.1" /> <PackageReference Include="Dapplo.Log.LogFile" Version="1.4.1" />
<PackageReference Include="Dapplo.Log.Loggers" Version="1.4.1" /> <PackageReference Include="Dapplo.Log.Loggers" Version="1.4.1" />
<PackageReference Include="Dapplo.Windows.Multimedia" Version="0.11.17" /> <PackageReference Include="Dapplo.Windows.Multimedia" Version="0.11.24" />
<PackageReference Include="gong-wpf-dragdrop" Version="2.3.2" /> <PackageReference Include="gong-wpf-dragdrop" Version="2.3.2" />
<PackageReference Include="sqlite-net-pcl" Version="1.7.335" /> <PackageReference Include="sqlite-net-pcl" Version="1.7.335" />
<PackageReference Include="Svg" Version="3.1.1" /> <PackageReference Include="Svg" Version="3.1.1" />
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="3.4.3" /> <PackageReference Include="Microsoft.AppCenter.Analytics" Version="4.1.0" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="3.4.3" /> <PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.1.0" />
<TrimmerRootAssembly Include="System.Diagnostics.Debug" /> <TrimmerRootAssembly Include="System.Diagnostics.Debug" />
</ItemGroup> </ItemGroup>