CommitteeCache.get_all_beacon_committees: set correct capacity to avoid realloc (#4557)

This commit is contained in:
zhiqiangxu 2023-08-02 23:50:43 +00:00
parent b5e25aeb2f
commit 7399a54ca3

View File

@ -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)