Repository navigation
Conversation
Replace the temporary vector with four stack entries, the maximum needed by the existing encoder on targets up to 64 bits. Check exact encodings around every power of two and at usize::MAX at all starting bit offsets. Written by OpenAI Codex.
Author
|
Draft until I finish iterating on it and hand-read & hand-test the code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
encode_naturalallocates a temporary vector for every encoded integer greater than one. Store its bounded suffix in a four-entry stack array and emit the populated entries in reverse order. On a 64-bit target the largest successive suffix lengths are 63, 5, 2, and 1; smaller pointer widths need no more entries. This retains the existing encoder assumption thatusizeis at most 64 bits.In warmed release-mode serialization benchmarks on macOS ARM64 with Rust 1.99, this independently reduced CPU time by 8.1% on the small fixture and 7.4% on the 2,048-leaf fixture (median of 33 paired samples). Allocations for the latter fell from 8,219 to 2,075. It does not change peak requested heap bytes in these fixtures. These are synthetic operation measurements, not application speedups.
Add exact-bit checks against a recursive specification around every representable power of two and at
usize::MAX, at all eight starting bit offsets. Keep the existing decoder round-trip test; the decoder's u32 limit cannot validate the encoder's full usize range.Validation:
cargo test --locked --workspace --all-features(121 library tests, 14 sys tests, 2 doctests)cargo test --locked -p simplicity-lang --lib --no-default-features(65 tests)cargo +1.74.0 test --offline --locked -p simplicity-lang --lib --all-features(121 tests)cargo fmt --all -- --checkcargo clippy --locked --workspace --all-targets --all-features -- --deny warningsusize::MAXWritten by OpenAI Codex.
Written with GPT 6.1 Sol on Extra High.