Set map initial cacacity in epoch cache builder

This should help reduce reallocations
This commit is contained in:
Paul Hauner 2019-03-14 20:54:44 +11:00
parent 96d96ba9ba
commit 8154397114
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6

View File

@ -33,12 +33,13 @@ impl EpochCache {
) -> Result<EpochCache, Error> {
let mut epoch_committees: Vec<CrosslinkCommittees> =
Vec::with_capacity(spec.slots_per_epoch as usize);
let mut attestation_duty_map: AttestationDutyMap = HashMap::new();
let mut shard_committee_index_map: ShardCommitteeIndexMap = HashMap::new();
let shuffling =
state.get_shuffling_for_slot(epoch.start_slot(spec.slots_per_epoch), false, spec)?;
let mut attestation_duty_map: AttestationDutyMap = HashMap::with_capacity(shuffling.len());
for (epoch_committeess_index, slot) in epoch.slot_iter(spec.slots_per_epoch).enumerate() {
let slot_committees = state.calculate_crosslink_committees_at_slot(
slot,