Repository: dotnet/runtime
File: src/libraries/System.Collections.Immutable/src/System/Linq/ImmutableArrayExtensions.cs (C#)

Code before:
            }

            comparer ??= EqualityComparer<TBase>.Default;

            for (int i = 0; i < immutableArray.Length; i++)
            {
                if (!comparer.Equals(immutableArray.array![i], items.array![i]))
                {
                    return false;
                }
            }

            return true;
        }

        /// <summary>
        /// Determines whether two sequences are equal according to an equality comparer.
        /// </summary>
        /// <typeparam name="TDerived">The type of element in the compared array.</typeparam>
        /// <typeparam name="TBase">The type of element contained by the collection.</typeparam>
        public static bool SequenceEqual<TDerived, TBase>(this ImmutableArray<TBase> immutableArray, IEnumerable<TDerived> items, IEqualityComparer<TBase>? comparer = null) where TDerived : TBase
        {
            if (items is ICollection<TBase> itemsCol)
            {
                immutableArray.ThrowNullRefIfNotInitialized();
                return Enumerable.SequenceEqual(immutableArray.array!, itemsCol, comparer);
            }

            return Impl(immutableArray, items, comparer);

            static bool Impl(ImmutableArray<TBase> immutableArray, IEnumerable<TDerived> items, IEqualityComparer<TBase>? comparer)
            {
                Requires.NotNull(items, nameof(items));

                comparer ??= EqualityComparer<TBase>.Default;

                int i = 0;
                int n = immutableArray.Length;
                foreach (TDerived item in items)
                {
                    if (i == n)
                    {
                        return false;
                    }

                    if (!comparer.Equals(immutableArray[i], item))
                    {
                        return false;
                    }

                    i++;

Review comment (suggestion):
```suggestion
                return Enumerable.SequenceEqual(immutableArray.array, itemsCol, comparer);
```

Not necessary after https://github.com/dotnet/runtime/pull/119898

Code after:
            }

            comparer ??= EqualityComparer<TBase>.Default;

            for (int i = 0; i < immutableArray.Length; i++)
            {
                if (!comparer.Equals(immutableArray.array[i], items.array[i]))
                {
                    return false;
                }
            }

            return true;
        }

        /// <summary>
        /// Determines whether two sequences are equal according to an equality comparer.
        /// </summary>
        /// <typeparam name="TDerived">The type of element in the compared array.</typeparam>
        /// <typeparam name="TBase">The type of element contained by the collection.</typeparam>
        public static bool SequenceEqual<TDerived, TBase>(this ImmutableArray<TBase> immutableArray, IEnumerable<TDerived> items, IEqualityComparer<TBase>? comparer = null) where TDerived : TBase
        {
            if (items is ICollection<TBase> itemsCol)
            {
                immutableArray.ThrowNullRefIfNotInitialized();
                return Enumerable.SequenceEqual(immutableArray.array, itemsCol, comparer);
            }

            return Enumerate(immutableArray, items, comparer);

            static bool Enumerate(ImmutableArray<TBase> immutableArray, IEnumerable<TDerived> items, IEqualityComparer<TBase>? comparer)
            {
                Requires.NotNull(items, nameof(items));

                comparer ??= EqualityComparer<TBase>.Default;

                int i = 0;
                int n = immutableArray.Length;
                foreach (TDerived item in items)
                {
                    if (i == n)
                    {
                        return false;
                    }

                    if (!comparer.Equals(immutableArray[i], item))
                    {
                        return false;
                    }

                    i++;