fix: inefficient Vec<u8> to BytesMut conversion #6687
Conversation
WalkthroughType signatures in zstd decoding and Ethereum transaction formatting functions are updated from BytesMut to Bytes return types. All call sites and tests are adapted accordingly, with .into() conversions where necessary. No control flow changes or new functionality introduced. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/eth/transaction.rs (1)
276-303: Add rustdoc on touched public formatting helpers.Line 276, Line 290, and Line 302 are public APIs and should have concise
///docs describing zero/negative/Nonebehavior.As per coding guidelines
Document all public functions and structs.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/eth/transaction.rs` around lines 276 - 303, Add concise rustdoc comments to each public helper: document format_u64 to explain it returns a big-endian minimal byte representation and returns an empty Bytes for zero; document format_bigint to state it returns big-endian magnitude bytes for positive values, returns an empty Bytes for zero, and errors for negative inputs (mention the error via bail!); and document format_address to describe that it accepts Option<EthAddress> and returns an empty Bytes when None and the address bytes when Some. Place these /// comments immediately above the corresponding function signatures (format_u64, format_bigint, format_address).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/eth/transaction.rs`:
- Around line 276-303: Add concise rustdoc comments to each public helper:
document format_u64 to explain it returns a big-endian minimal byte
representation and returns an empty Bytes for zero; document format_bigint to
state it returns big-endian magnitude bytes for positive values, returns an
empty Bytes for zero, and errors for negative inputs (mention the error via
bail!); and document format_address to describe that it accepts
Option<EthAddress> and returns an empty Bytes when None and the address bytes
when Some. Place these /// comments immediately above the corresponding function
signatures (format_u64, format_bigint, format_address).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c02029b6-614f-4100-a049-09fd1b88b935
📒 Files selected for processing (2)
src/db/car/forest.rssrc/eth/transaction.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 11 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Summary of changes
Vec<u8>cannot be directly converted toBytesMut,vec.into_iter().collect()should be less efficient thanBytesMut::from(Bytes::from(vec))https://docs.rs/bytes/latest/src/bytes/bytes_mut.rs.html#918
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit