|
1 | | -## 2026-02-25 — Optimize codec header decoding with direct bitwise operations |
2 | | - |
3 | | -**Done:** Replaced `Vec<bool>` intermediate allocation in `decode_header` and `decode_varnibble` |
4 | | -with direct bitwise extraction from the byte slice. Added `get_bit` and `extract_bits` helpers that |
5 | | -operate on `&[u8]` + bit position. Gated `bytes_to_bits` and `bits_to_u32` with `#[cfg(test)]` since |
6 | | -they're only used by test helpers after the rewrite. |
7 | | - |
8 | | -**Files changed:** |
9 | | - |
10 | | -- `crates/iscc-lib/src/codec.rs`: Added `get_bit`, `extract_bits`, `decode_varnibble_from_bytes` |
11 | | - functions; rewrote `decode_header` to use byte-based decoding; gated `bytes_to_bits` and |
12 | | - `bits_to_u32` with `#[cfg(test)]`; updated `test_varnibble_roundtrip` to use new function; added |
13 | | - `test_extract_bits_basic` and `test_decode_varnibble_from_bytes_boundary_values` tests |
14 | | - |
15 | | -**Verification:** All 261 tests pass (208 unit + 31 algo primitives + 22 text utils). Clippy clean |
16 | | -(workspace-wide `--all-targets`). All 14 pre-commit hooks pass. Benchmark shows 27% improvement for |
17 | | -`gen_mixed_code_v0` (1.34µs → was ~1.87µs). Benchmark runs without error. |
18 | | - |
19 | | -**Next:** The codec issue (`[normal] Codec header parsing expands bytes to Vec<bool>`) is now |
20 | | -resolved and can be deleted from issues.md. Consider addressing `DataHasher::update` buffer |
21 | | -allocation (`[normal]`), iscc-ffi video frame allocation (`[normal]`), or lower-priority items. |
22 | | - |
23 | | -**Notes:** The old `decode_varnibble` function was removed entirely (no production or test callers |
24 | | -remain after updating `test_varnibble_roundtrip`). Clippy suggested two improvements: collapsing the |
25 | | -nested `if` in the padding check into a single condition, and using `bit_pos.div_ceil(8)` instead of |
26 | | -`(bit_pos + 7) / 8`. Both applied. The tail extraction behavior is slightly cleaner for invalid data |
27 | | -(non-zero padding) — it now rounds up to the next byte boundary instead of reconstructing mid-byte |
28 | | -tail data through `bits_to_bytes`, but this difference is invisible for valid ISCC data where |
29 | | -padding is always zero. |
| 1 | +## 2026-02-25 — Review of: Optimize codec header decoding with direct bitwise operations |
| 2 | + |
| 3 | +**Verdict:** PASS |
| 4 | + |
| 5 | +**Summary:** Replaced `Vec<bool>` intermediate allocation in `decode_header` and `decode_varnibble` |
| 6 | +with direct bitwise extraction from `&[u8]`. Implementation is clean, minimal, and matches the |
| 7 | +next.md specification exactly. All 261 tests pass, clippy is clean, and all 14 pre-commit hooks |
| 8 | +pass. |
| 9 | + |
| 10 | +**Verification:** |
| 11 | + |
| 12 | +- [x] `cargo test -p iscc-lib` passes — 261 tests (208 unit + 31 algo + 22 text), including 2 new |
| 13 | + bitwise extraction tests |
| 14 | +- [x] `cargo clippy -p iscc-lib -- -D warnings` clean |
| 15 | +- [x] `bytes_to_bits` gated with `#[cfg(test)]` — no longer in production code path |
| 16 | +- [x] `Vec<bool>` only in `encode_varnibble` and test-gated helpers, NOT in `decode_header` or any |
| 17 | + decode function |
| 18 | +- [x] `cargo bench -p iscc-lib -- gen_mixed_code_v0` runs without error — 1.35µs median |
| 19 | + |
| 20 | +**Issues found:** |
| 21 | + |
| 22 | +- (none) |
| 23 | + |
| 24 | +**Next:** The codec `Vec<bool>` issue is resolved. Consider addressing `DataHasher::update` buffer |
| 25 | +allocation (`[normal]` in issues.md), iscc-ffi video frame allocation (`[normal]`), or one of the |
| 26 | +`[low]` issues. Alternatively, if there are remaining target.md gaps, those take priority. |
| 27 | + |
| 28 | +**Notes:** The old `decode_varnibble` function was fully removed (not just gated). The roundtrip |
| 29 | +test was properly updated to use the new `decode_varnibble_from_bytes` via `bits_to_bytes` |
| 30 | +conversion. Benchmark shows ~1.35µs for `gen_mixed_code_v0` — consistent with the advance agent's |
| 31 | +reported 27% improvement from baseline. |
0 commit comments