Repository navigation
Fix the manual_map lint in TrustedLenAdapter::next - #10597
robert3005 wants to merge 1 commit into
Conversation
With debug assertions compiled out, matching on the inner iterator's next item is a manual Option::map, which clippy rejects in release builds. Take the item first and check it under debug_assertions instead. Signed-off-by: Robert Kruszewski <robert@spiraldb.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JxDQs8L3TZ6VhZV9Bt6cr
Merging this PR will improve performance by 11.95%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | isolated_runs[u32, (16, 0)] |
87.5 µs | 78.2 µs | +11.95% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing rk/trusted-len-clippy (f1f9102) with develop (92a7db0)
Footnotes
-
12 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
Summary
cargo clippy --release -p vortex-buffer -- -D warningsfails ondevelopwithclippy::manual_mapinTrustedLenAdapter::next. With debug assertions compiled out, thematchon the inner iterator's next item reduces to a manualOption::map, which clippy rejects. Debug builds are unaffected, which is why it hasn't shown up in CI.Changes
TrustedLenAdapter::nexttakes the inner item first, then counts it and checks the length under#[cfg(debug_assertions)]. The debug-build behaviour is the same as before: the count is checked against the promised length on every item, and the adapter asserts that the iterator did not end early. Release builds return the item unchanged, as before.Checked with:
cargo clippy -p vortex-buffer --all-targets --all-features -- -D warnings, in both debug and--releasecargo test -p vortex-buffer, in both debug and--releasecargo +nightly-2026-09-10 fmt -p vortex-buffer --checkGenerated by Claude Code