Skip to content

Commit

Permalink
set correct capacity to avoid realloc
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqiangxu committed Aug 2, 2023
1 parent 73764d0 commit 71bcd06
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion consensus/types/src/beacon_state/committee_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl CommitteeCache {
.ok_or(Error::CommitteeCacheUninitialized(None))?;

initialized_epoch.slot_iter(self.slots_per_epoch).try_fold(
Vec::with_capacity(self.slots_per_epoch as usize),
Vec::with_capacity(self.epoch_committee_count()),
|mut vec, slot| {
vec.append(&mut self.get_beacon_committees_at_slot(slot)?);
Ok(vec)
Expand Down

0 comments on commit 71bcd06

Please sign in to comment.