Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(db): use Into to encode StoredNibbles #11350

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ impl TransactionSignedNoHash {
/// Recover signer from signature and hash _without ensuring that the signature has a low `s`
/// value_.
///
/// Re-uses a given buffer to avoid numerous reallocations when recovering batches. **Clears the
/// Reuses a given buffer to avoid numerous reallocations when recovering batches. **Clears the
/// buffer before use.**
///
/// Returns `None` if the transaction's signature is invalid, see also
Expand Down
6 changes: 3 additions & 3 deletions crates/storage/db-api/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ impl Encode for StoredNibbles {

// Delegate to the Compact implementation
fn encode(self) -> Self::Encoded {
let mut buf = Vec::with_capacity(self.0.len());
self.to_compact(&mut buf);
buf
// NOTE: This used to be `to_compact`, but all it does is append the bytes to the buffer,
// so we can just use the implementation of `Into<Vec<u8>>` to reuse the buffer.
self.0.into()
}
}

Expand Down
Loading