mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-10 19:51:20 +00:00
attestationutil.AttestingIndices: Minor improvement on indices array allocation (#6508)
* attestationutil.AttestingIndices: Minor improvement on indices array allocation * Merge branch 'master' of github.com:prysmaticlabs/prysm into HEAD * Merge refs/heads/master into memory1 * Merge refs/heads/master into memory1 * Merge refs/heads/master into memory1 * Merge refs/heads/master into memory1 * Merge refs/heads/master into memory1 * Merge refs/heads/master into memory1 * Merge refs/heads/master into memory1 * Merge refs/heads/master into memory1 * Merge refs/heads/master into memory1 * Merge refs/heads/master into memory1
This commit is contained in:
parent
a279f18461
commit
f2f2677070
@ -67,7 +67,7 @@ func ConvertToIndexed(ctx context.Context, attestation *ethpb.Attestation, commi
|
||||
// committee = get_beacon_committee(state, data.slot, data.index)
|
||||
// return set(index for i, index in enumerate(committee) if bits[i])
|
||||
func AttestingIndices(bf bitfield.Bitfield, committee []uint64) []uint64 {
|
||||
indices := make([]uint64, 0, len(committee))
|
||||
indices := make([]uint64, 0, bf.Count())
|
||||
for _, idx := range bf.BitIndices() {
|
||||
if idx < len(committee) {
|
||||
indices = append(indices, committee[idx])
|
||||
|
@ -114,9 +114,10 @@ func TestIsValidAttestationIndices(t *testing.T) {
|
||||
}
|
||||
|
||||
func BenchmarkAttestingIndices_PartialCommittee(b *testing.B) {
|
||||
bf := bitfield.Bitlist{0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b100}
|
||||
bf := bitfield.Bitlist{0b11111111, 0b11111111, 0b10000111, 0b11111111, 0b100}
|
||||
committee := []uint64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34}
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = attestationutil.AttestingIndices(bf, committee)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user