Skip to content

Commit

Permalink
fix: don't preallocate collections in Events
Browse files Browse the repository at this point in the history
Signed-off-by: ljedrz <[email protected]>
  • Loading branch information
ljedrz committed Oct 4, 2023
1 parent 0c01473 commit 86a352f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion node/narwhal/events/src/worker_ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<N: Network> ToBytes for WorkerPing<N> {
impl<N: Network> FromBytes for WorkerPing<N> {
fn read_le<R: Read>(mut reader: R) -> IoResult<Self> {
let num_transmissions = u32::read_le(&mut reader)?;
let mut transmission_ids = IndexSet::with_capacity(num_transmissions as usize);
let mut transmission_ids = IndexSet::new();
for _ in 0..num_transmissions {
transmission_ids.insert(TransmissionID::read_le(&mut reader)?);
}
Expand Down
4 changes: 2 additions & 2 deletions node/sync/locators/src/block_locators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl<N: Network> FromBytes for BlockLocators<N> {
// Read the number of recent block hashes.
let num_recents = u32::read_le(&mut reader)?;
// Read the recent block hashes.
let mut recents = IndexMap::with_capacity(num_recents as usize);
let mut recents = IndexMap::new();
for _ in 0..num_recents {
let height = u32::read_le(&mut reader)?;
let hash = N::BlockHash::read_le(&mut reader)?;
Expand All @@ -274,7 +274,7 @@ impl<N: Network> FromBytes for BlockLocators<N> {
// Read the number of checkpoints.
let num_checkpoints = u32::read_le(&mut reader)?;
// Read the checkpoints.
let mut checkpoints = IndexMap::with_capacity(num_checkpoints as usize);
let mut checkpoints = IndexMap::new();
for _ in 0..num_checkpoints {
let height = u32::read_le(&mut reader)?;
let hash = N::BlockHash::read_le(&mut reader)?;
Expand Down

0 comments on commit 86a352f

Please sign in to comment.