Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixes

- Fix UWP Net Native compilation ([#4085](https://github.com/getsentry/sentry-dotnet/pull/4085))
- Sentry Java SDK dependencies are now detected and included in the Android bindings ([#4079](https://github.com/getsentry/sentry-dotnet/pull/4079))

## 5.5.0
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