Skip to content

Commit

Permalink
refactor(data_structures): avoid iterating twice over the same vector
Browse files Browse the repository at this point in the history
Get the pkh and call `to_string` in the same `.map` instead of doing it in two
different iterations.
  • Loading branch information
Tommytrg committed Oct 18, 2023
1 parent 5a7c8b7 commit 7ab51a9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions data_structures/src/superblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ impl SuperBlockVotesMempool {
|mut acc, (superblock_hash, votes)| {
let pkhs: Vec<String> = 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!(
Expand Down

0 comments on commit 7ab51a9

Please sign in to comment.