Skip to content

Commit

Permalink
Revert "Shorten UTD marker file (dotnet#9387)" except Microsoft.Commo…
Browse files Browse the repository at this point in the history
…n.CurrentVersion.targets
  • Loading branch information
JanKrivanek committed Dec 12, 2023
1 parent 9276c4e commit 90fce82
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 144 deletions.
5 changes: 2 additions & 3 deletions src/Build/Evaluation/IntrinsicFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Microsoft.Build.Shared;
using Microsoft.Build.Shared.FileSystem;
using Microsoft.Build.Utilities;
using Microsoft.NET.StringTools;
using Microsoft.Win32;

// Needed for DoesTaskHostExistForParameters
Expand Down Expand Up @@ -399,11 +398,11 @@ internal static string ConvertFromBase64(string toDecode)
}

/// <summary>
/// Hash the string independent of bitness, target framework and default codepage of the environment.
/// Hash the string independent of bitness and target framework.
/// </summary>
internal static int StableStringHash(string toHash)
{
return FowlerNollVo1aHash.ComputeHash32(toHash);
return CommunicationsUtilities.GetHashCode(toHash);
}

/// <summary>
Expand Down
40 changes: 34 additions & 6 deletions src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Framework.Profiler;
using Microsoft.Build.Shared;
using Microsoft.Build.Utilities;
using Microsoft.NET.StringTools;

#nullable disable

Expand Down Expand Up @@ -1261,9 +1259,9 @@ private void Write(IExtendedBuildEventArgs extendedData)

internal readonly struct HashKey : IEquatable<HashKey>
{
private readonly long value;
private readonly ulong value;

private HashKey(long i)
private HashKey(ulong i)
{
value = i;
}
Expand All @@ -1276,13 +1274,13 @@ public HashKey(string text)
}
else
{
value = FowlerNollVo1aHash.ComputeHash64Fast(text);
value = FnvHash64.GetHashCode(text);
}
}

public static HashKey Combine(HashKey left, HashKey right)
{
return new HashKey(FowlerNollVo1aHash.Combine64(left.value, right.value));
return new HashKey(FnvHash64.Combine(left.value, right.value));
}

public HashKey Add(HashKey other) => Combine(this, other);
Expand Down Expand Up @@ -1312,5 +1310,35 @@ public override string ToString()
return value.ToString();
}
}

internal static class FnvHash64
{
public const ulong Offset = 14695981039346656037;
public const ulong Prime = 1099511628211;

public static ulong GetHashCode(string text)
{
ulong hash = Offset;

unchecked
{
for (int i = 0; i < text.Length; i++)
{
char ch = text[i];
hash = (hash ^ ch) * Prime;
}
}

return hash;
}

public static ulong Combine(ulong left, ulong right)
{
unchecked
{
return (left ^ right) * Prime;
}
}
}
}
}
135 changes: 0 additions & 135 deletions src/StringTools/FowlerNollVo1aHash.cs

This file was deleted.

0 comments on commit 90fce82

Please sign in to comment.