Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
Expand Down Expand Up @@ -49,6 +49,7 @@ The System.Reflection.Metadata library is built-in as part of the shared framewo
<Compile Include="System\Reflection\Metadata\BlobWriterImpl.cs" />
<Compile Include="System\Reflection\Metadata\BlobBuilder.cs" />
<Compile Include="System\Reflection\Metadata\BlobBuilder.Enumerators.cs" />
<Compile Include="System\Reflection\Metadata\BlobBuilder.Segment.cs" />
<Compile Include="System\Reflection\Internal\Utilities\DecimalUtilities.cs" />
<Compile Include="System\Reflection\Internal\Utilities\EnumerableExtensions.cs" />
<Compile Include="System\Reflection\Metadata\Ecma335\CustomAttributeDecoder.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Immutable;

namespace System.Reflection.Internal
{
internal static class Hash
Expand Down Expand Up @@ -40,13 +38,20 @@ internal static int Combine(bool newKeyPart, int currentKey)
/// </summary>
/// <param name="data">The sequence of bytes</param>
/// <returns>The FNV-1a hash of <paramref name="data"/></returns>
internal static int GetFNVHashCode(ReadOnlySpan<byte> data)
{
int hashCode = Hash.FnvOffsetBias;
internal static int GetFNVHashCode(ReadOnlySpan<byte> data) => AccumulateFNVHashCode(FnvOffsetBias, data);

/// <summary>
/// Compute the FNV-1a hash of a sequence of bytes
/// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
/// </summary>
/// <param name="hashCode">The current hash code</param>
/// <param name="data">The sequence of bytes</param>
/// <returns>The updated hash code</returns>
internal static int AccumulateFNVHashCode(int hashCode, ReadOnlySpan<byte> data)
{
for (int i = 0; i < data.Length; i++)
{
hashCode = unchecked((hashCode ^ data[i]) * Hash.FnvPrime);
hashCode = unchecked((hashCode ^ data[i]) * FnvPrime);
}

return hashCode;
Expand Down
Loading
Loading