ArrayExtensions.IsSequenceEqual — Use MemoryExtensions.SequenceEqual

Open Beginner friendly
#142 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Stale
Tech stack
csharp
Domain
performance

Research direction

Open Utilities/ArrayExtensions.cs and locate ArrayExtensions.IsSequenceEqual. Compare the current equality loop with the proposed AsSpan().SequenceEqual approach, then run the repository's existing test suite to confirm behavior for the relevant array comparisons. Done means the method uses MemoryExtensions.SequenceEqual without per-element boxing and existing tests pass.

Written by the indexing model from the issue text.

Description

agent enhancement

File: Utilities/ArrayExtensions.cs

The hand-rolled equality loop uses boxed Equals(source[i], other[i]) — that's virtual dispatch and boxing for every element.

// BEFORE
if (!Equals(source[i], other[i])) ...

// AFTER — intrinsic-optimised, SIMD-enabled on .NET 8
return source.AsSpan().SequenceEqual(other.AsSpan());

MemoryExtensions.SequenceEqual is SIMD-vectorised by the JIT on .NET 8 and avoids all boxing. For long[] comparisons across the histogram counts array (which can be ~185KB), this is material.

Dominant language
C#
Stars
185
Forks
31
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HdrHistogram/HdrHistogram.NET

All issues in HdrHistogram/HdrHistogram.NET

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.