Skip to content

Commit

Permalink
chore: simplify word_rlp (#87)
Browse files Browse the repository at this point in the history
Generates identical assembly, but looks nicer.
  • Loading branch information
DaniPopes authored Feb 20, 2025
1 parent 1825c77 commit 27e8935
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/nodes/rlp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ impl RlpNode {
/// RLP-encodes the given word and returns it as a new RLP node.
#[inline]
pub fn word_rlp(word: &B256) -> Self {
let mut arr = ArrayVec::new();
arr.push(EMPTY_STRING_CODE + 32);
arr.try_extend_from_slice(word.as_slice()).unwrap();
Self(arr)
let mut arr = [0u8; 33];
arr[0] = EMPTY_STRING_CODE + 32;
arr[1..].copy_from_slice(word.as_slice());
Self(ArrayVec::from(arr))
}

/// Returns the RLP-encoded node as a slice.
Expand Down

0 comments on commit 27e8935

Please sign in to comment.