From 190525213ae6d83fa7389c7fdd0d25ee71a728be Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 19 Feb 2025 23:48:58 +0100 Subject: [PATCH] chore: simplify word_rlp Generates identical assembly, but looks nicer. --- src/nodes/rlp.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nodes/rlp.rs b/src/nodes/rlp.rs index c858327..05e6ffe 100644 --- a/src/nodes/rlp.rs +++ b/src/nodes/rlp.rs @@ -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.