mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-02 12:24:29 +00:00
Improve allocation in get_attestation_participants
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user