From 95f5cd28fc1d7b290f4f42a30de14224e3533909 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 20 Oct 2022 03:28:45 +0200 Subject: [PATCH] Remove unused equality extensions --- .../ComputeSharp.SourceGeneration.projitems | 2 - .../Extensions/HashCodeExtensions.cs | 40 --------------- .../Extensions/ImmutableArrayExtensions.cs | 50 ------------------- 3 files changed, 92 deletions(-) delete mode 100644 src/ComputeSharp.SourceGeneration/Extensions/HashCodeExtensions.cs delete mode 100644 src/ComputeSharp.SourceGeneration/Extensions/ImmutableArrayExtensions.cs diff --git a/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems b/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems index b17d1faf..05057cf3 100644 --- a/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems +++ b/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems @@ -13,8 +13,6 @@ - - diff --git a/src/ComputeSharp.SourceGeneration/Extensions/HashCodeExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/HashCodeExtensions.cs deleted file mode 100644 index 15592c78..00000000 --- a/src/ComputeSharp.SourceGeneration/Extensions/HashCodeExtensions.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; - -namespace ComputeSharp.SourceGeneration.Extensions; - -/// -/// Extension methods for . -/// -internal static class HashCodeExtensions -{ - /// - /// Adds all items from a given instance to an hashcode. - /// - /// The type of items to hash. - /// The target instance. - /// The input items to hash. - public static void AddRange(this ref HashCode hashCode, ImmutableArray items) - { - foreach (T item in items) - { - hashCode.Add(item); - } - } - - /// - /// Adds all items from a given instance to an hashcode. - /// - /// The type of items to hash. - /// The target instance. - /// A comparer to get hashcodes for items. - /// The input items to hash. - public static void AddRange(this ref HashCode hashCode, ImmutableArray items, IEqualityComparer comparer) - { - foreach (T item in items) - { - hashCode.Add(item, comparer); - } - } -} \ No newline at end of file diff --git a/src/ComputeSharp.SourceGeneration/Extensions/ImmutableArrayExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/ImmutableArrayExtensions.cs deleted file mode 100644 index 9b8b6a77..00000000 --- a/src/ComputeSharp.SourceGeneration/Extensions/ImmutableArrayExtensions.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; - -namespace ComputeSharp.SourceGeneration.Extensions; - -/// -/// Extension methods for . -/// -internal static class ImmutableArrayExtensions -{ - /// - /// Compares two sequences for equality. - /// - /// The items to compare. - /// The left sequence of items. - /// The right sequence of items. - /// Whether or not equals . - public static bool SequenceEqual(this ImmutableArray left, ImmutableArray right) - where T : IEquatable - { - return left.AsSpan().SequenceEqual(right.AsSpan()); - } - - /// - /// Compares two sequences for equality. - /// - /// The items to compare. - /// The left sequence of items. - /// The right sequence of items. - /// The instance used to compare items. - /// Whether or not equals . - public static bool SequenceEqual(this ImmutableArray left, ImmutableArray right, IEqualityComparer comparer) - { - if (left.Length != right.Length) - { - return false; - } - - for (int i = 0; i < left.Length; i++) - { - if (!comparer.Equals(left[i], right[i])) - { - return false; - } - } - - return true; - } -} \ No newline at end of file