Improve allocation in get_attestation_participants
This commit is contained in:
parent
53456a6c79
commit
a44d80006a
@ -531,12 +531,14 @@ impl BeaconState {
|
|||||||
return Err(Error::InvalidBitfield);
|
return Err(Error::InvalidBitfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut participants = vec![];
|
let mut participants = Vec::with_capacity(committee.len());
|
||||||
for (i, validator_index) in committee.iter().enumerate() {
|
for (i, validator_index) in committee.iter().enumerate() {
|
||||||
if bitfield.get(i).unwrap() {
|
match bitfield.get(i) {
|
||||||
participants.push(*validator_index);
|
Ok(bit) if bit == true => participants.push(*validator_index),
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
participants.shrink_to_fit();
|
||||||
|
|
||||||
Ok(participants)
|
Ok(participants)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user