Skip to content

Conversation

@alexdegroot
Copy link

@alexdegroot alexdegroot commented Feb 24, 2025

Rationale for this change

Improve the performance of the GetBit operations by avoiding array allocation everytime method get used.

What changes are included in this PR?

Small changes to the class where the PopcountTable and BitMask both become static readonly byte-arrays.

Are these changes tested?

Yes, all changes pass

Are there any user-facing changes?

No breaking changes.

@github-actions
Copy link

⚠️ GitHub issue #45559 has been automatically assigned in GitHub to PR creator.

Copy link
Contributor

@CurtHagenlocher CurtHagenlocher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you benchmarked to confirm whether this change makes any performance difference? It's my understanding -- backed up by an experiment with SharpLab -- that the C# compiler translates the idiom static ReadOnlySpan<byte> Property => new byte[] { ... }; into a reference directly into static data. (The C# compiler PR in question is dotnet/roslyn#24621.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants