Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Fix UWP Net Native compilation ([#4085](https://github.com/getsentry/sentry-dotnet/pull/4085))

## 5.5.0

### Features
Expand Down
36 changes: 10 additions & 26 deletions src/Sentry/Internal/FnvHash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,23 @@ namespace Sentry.Internal;
///
/// See https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV_hash_parameters
/// </summary>
/// <remarks>
/// We use a struct to avoid heap allocations.
/// </remarks>
internal struct FnvHash
internal static class FnvHash
{
public FnvHash()
{
}

private const int Offset = unchecked((int)2166136261);
private const int Prime = 16777619;

private int HashCode { get; set; } = Offset;

private void Combine(byte data)
{
unchecked
{
HashCode ^= data;
HashCode *= Prime;
}
}

private static int ComputeHash(byte[] data)
internal static int ComputeHash(string input)
{
var result = new FnvHash();
foreach (var b in data)
var hashCode = Offset;
foreach (var b in Encoding.UTF8.GetBytes(input))
{
result.Combine(b);
unchecked
{
hashCode ^= b;
hashCode *= Prime;
}
}

return result.HashCode;
return hashCode;
}

public static int ComputeHash(string data) => ComputeHash(Encoding.UTF8.GetBytes(data));
}
Loading