Skip to content

refactor: require disjoint DecompressTo buffers - #13

Merged
ChillerDragon merged 1 commit into
teeworlds-go:masterfrom
jxsl13:codex/huffman-api-safety
Aug 20, 2026
Merged

ChillerDragon merged 1 commit into
teeworlds-go:masterfrom
jxsl13:codex/huffman-api-safety

Conversation

@jxsl13

@jxsl13 jxsl13 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #12.

Change

DecompressTo now explicitly requires dst and data to use disjoint backing storage. Passing aliased or overlapping slices is invalid API use.

This removes the runtime overlap detector, its unsafe import and address arithmetic. It deliberately does not replace them with reflect. The overlap-specific tests are removed because overlap is no longer a supported contract.

Normal append-style buffer reuse remains unchanged and allocation-free when input and output buffers are distinct.

Rationale

Aliasing compressed input with writable output storage is a caller error and is not needed by the Teeworlds/DDNet packet path. Making that precondition explicit keeps the hot path simple, avoids architecture-dependent address inspection, and removes the exceptional source copy.

Verification

  • go test ./...
  • go test -race ./...
  • go test -gcflags=all=-d=checkptr=2 ./...
  • go vet ./...
  • staticcheck ./...
  • Cross-compiled test binaries for linux/386, linux/arm, and windows/386
  • Full test suite passed in an actual linux/386 container
  • Alternating full benchmark suite against current upstream/master: 0.52% lower geomean time; allocation counts unchanged

@ChillerDragon
ChillerDragon merged commit 56b4227 into teeworlds-go:master Aug 20, 2026
1 check passed
@ChillerDragon

Copy link
Copy Markdown
Member

e okay? Xd

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.

2 participants