Skip to content

Commit

Permalink
remove some unused stuff in Util, fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Dec 29, 2024
1 parent 1aada98 commit 6dd85c9
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions Dalamud/Utility/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public static class Util
private static readonly Type GenericSpanType = typeof(Span<>);
private static string? scmVersionInternal;
private static string? gitHashInternal;
private static int? gitCommitCountInternal;
private static string? gitHashClientStructsInternal;

private static ulong moduleStartAddr;
Expand All @@ -77,58 +76,6 @@ public static class Util
public static string AssemblyVersion { get; } =
Assembly.GetAssembly(typeof(ChatHandlers)).GetName().Version.ToString();

/// <summary>
/// Check two byte arrays for equality.
/// </summary>
/// <param name="a1">The first byte array.</param>
/// <param name="a2">The second byte array.</param>
/// <returns>Whether or not the byte arrays are equal.</returns>
public static unsafe bool FastByteArrayCompare(byte[]? a1, byte[]? a2)
{
// Copyright (c) 2008-2013 Hafthor Stefansson
// Distributed under the MIT/X11 software license
// Ref: http://www.opensource.org/licenses/mit-license.php.
// https://stackoverflow.com/a/8808245

if (a1 == a2) return true;
if (a1 == null || a2 == null || a1.Length != a2.Length)
return false;
fixed (byte* p1 = a1, p2 = a2)
{
byte* x1 = p1, x2 = p2;
var l = a1.Length;
for (var i = 0; i < l / 8; i++, x1 += 8, x2 += 8)
{
if (*((long*)x1) != *((long*)x2))
return false;
}

if ((l & 4) != 0)
{
if (*((int*)x1) != *((int*)x2))
return false;
x1 += 4;
x2 += 4;
}

if ((l & 2) != 0)
{
if (*((short*)x1) != *((short*)x2))
return false;
x1 += 2;
x2 += 2;
}

if ((l & 1) != 0)
{
if (*((byte*)x1) != *((byte*)x2))
return false;
}

return true;
}
}

/// <summary>
/// Gets the SCM Version from the assembly, or null if it cannot be found. This method will generally return
/// the <c>git describe</c> output for this build, which will be a raw version if this is a stable build or an
Expand Down

0 comments on commit 6dd85c9

Please sign in to comment.