From 7ab51a90a1af67c9f88eebff1e9b8f19569393ea Mon Sep 17 00:00:00 2001 From: tommytrg Date: Wed, 18 Oct 2023 16:38:59 +0200 Subject: [PATCH] refactor(data_structures): avoid iterating twice over the same vector Get the pkh and call `to_string` in the same `.map` instead of doing it in two different iterations. --- data_structures/src/superblock.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/data_structures/src/superblock.rs b/data_structures/src/superblock.rs index e87eef56c..7e3d30ad3 100644 --- a/data_structures/src/superblock.rs +++ b/data_structures/src/superblock.rs @@ -163,8 +163,7 @@ impl SuperBlockVotesMempool { |mut acc, (superblock_hash, votes)| { let pkhs: Vec = votes .iter() - .map(|vote| vote.secp256k1_signature.public_key.pkh()) - .map(|pkh| pkh.to_string()) + .map(|vote| vote.secp256k1_signature.public_key.pkh().to_string()) .collect(); acc.push_str(&format!(