Skip to content

chore: scoped public span params + CountLeadingZeros test/benchmark cleanup#6

Merged
unsafePtr merged 2 commits into
masterfrom
chore/unsafe-clean-up
Jul 21, 2026
Merged

chore: scoped public span params + CountLeadingZeros test/benchmark cleanup#6
unsafePtr merged 2 commits into
masterfrom
chore/unsafe-clean-up

Conversation

@unsafePtr

Copy link
Copy Markdown
Owner

Summary

Two small, dependency-free cleanups to the Base58 library:

  1. Defensive scoped on public span parameters — annotate the public Encode/Decode ReadOnlySpan/Span parameters with scoped (mirrors MessagePack-CSharp #2271). Documents and compiler-enforces that the API never captures caller buffers. No codegen change, non-breaking.

  2. CountLeadingZeros test + benchmark cleanup — retarget the leading-zero tests from now-deleted internals to the public CountLeadingZeros contract (plus an all-zeros case and deterministic inputs), and add an IndexOfAnyExcept variant to CountLeadingZerosBenchmark that records the measured result: the BCL span-scan is ~27% slower than the hand-rolled SIMD path, so it was measured and not adopted.

Parked for later

A separate SIMD / table-layout exploration (flattening the uint[][] lookup tables, TensorPrimitives.Dot) is kept on a local experiment/base58-simd-tables branch. TensorPrimitives.Dot<ulong> showed a real decode kernel win but requires an ML-math (System.Numerics.Tensors) dependency, and firedancer itself keeps the matrix-multiply scalar — so it needs more end-to-end evaluation before adopting. Not part of this PR.

Testing

  • 123 unit tests pass (1 skipped: local-only big-endian test).
  • Benchmark project builds clean.

@unsafePtr
unsafePtr merged commit 44f61ac into master Jul 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant