Simplify make call by omitting redundant arguments (#6949)

* removed redundant args
* Merge refs/heads/master into omit-redundant-make-args
This commit is contained in:
rkapka
2020-08-10 13:06:53 +02:00
committed by GitHub
parent 44f9d07434
commit 33105f1bbc
9 changed files with 14 additions and 14 deletions

View File

@@ -83,8 +83,8 @@ func ComputeShuffledIndex(index uint64, indexCount uint64, seed [32]byte, shuffl
// effectively un-shuffling the list.
round = rounds - 1
}
buf := make([]byte, totalSize, totalSize)
posBuffer := make([]byte, 8, 8)
buf := make([]byte, totalSize)
posBuffer := make([]byte, 8)
hashfunc := hashutil.CustomSHA256Hasher()
// Seed is always the first 32 bytes of the hash input, we never have to change this part of the buffer.
@@ -168,7 +168,7 @@ func innerShuffleList(input []uint64, seed [32]byte, shuffle bool) ([]uint64, er
return input, nil
}
listSize := uint64(len(input))
buf := make([]byte, totalSize, totalSize)
buf := make([]byte, totalSize)
r := uint8(0)
if !shuffle {
r = rounds - 1

View File

@@ -110,7 +110,7 @@ func BenchmarkShuffleList(b *testing.B) {
listSizes := []uint64{400000, 40000, 400}
seed := [32]byte{123, 42}
for _, listSize := range listSizes {
testIndices := make([]uint64, listSize, listSize)
testIndices := make([]uint64, listSize)
for i := uint64(0); i < listSize; i++ {
testIndices[i] = i
}

View File

@@ -50,7 +50,7 @@ func runShuffleTest(testCase *ShuffleTestCase) error {
}
seed := common.BytesToHash(baseSeed)
testIndices := make([]uint64, testCase.Count, testCase.Count)
testIndices := make([]uint64, testCase.Count)
for i := uint64(0); i < testCase.Count; i++ {
testIndices[i] = i
}

View File

@@ -521,7 +521,7 @@ func TestServer_ListAttestations_Pagination_DefaultPageSize(t *testing.T) {
func TestServer_mapAttestationToTargetRoot(t *testing.T) {
count := uint64(100)
atts := make([]*ethpb.Attestation, count, count)
atts := make([]*ethpb.Attestation, count)
targetRoot1 := bytesutil.ToBytes32([]byte("root1"))
targetRoot2 := bytesutil.ToBytes32([]byte("root2"))
@@ -606,7 +606,7 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) {
state, _ := testutil.DeterministicGenesisState(t, numValidators)
// Next up we convert the test attestations to indexed form:
indexedAtts := make([]*ethpb.IndexedAttestation, len(atts)+len(atts2), len(atts)+len(atts2))
indexedAtts := make([]*ethpb.IndexedAttestation, len(atts)+len(atts2))
for i := 0; i < len(atts); i++ {
att := atts[i]
committee, err := helpers.BeaconCommitteeFromState(state, att.Data.Slot, att.Data.CommitteeIndex)
@@ -707,7 +707,7 @@ func TestServer_ListIndexedAttestations_OldEpoch(t *testing.T) {
require.NoError(t, state.SetSlot(startSlot))
// Next up we convert the test attestations to indexed form:
indexedAtts := make([]*ethpb.IndexedAttestation, len(atts), len(atts))
indexedAtts := make([]*ethpb.IndexedAttestation, len(atts))
for i := 0; i < len(atts); i++ {
att := atts[i]
committee, err := helpers.BeaconCommitteeFromState(state, att.Data.Slot, att.Data.CommitteeIndex)

View File

@@ -122,7 +122,7 @@ func merkleizeTrieLeaves(layers [][][32]byte, hashLayer [][32]byte,
chunkBuffer := bytes.NewBuffer([]byte{})
chunkBuffer.Grow(64)
for len(hashLayer) > 1 && i < len(layers) {
layer := make([][32]byte, len(hashLayer)/2, len(hashLayer)/2)
layer := make([][32]byte, len(hashLayer)/2)
for j := 0; j < len(hashLayer); j += 2 {
chunkBuffer.Write(hashLayer[j][:])
chunkBuffer.Write(hashLayer[j+1][:])

View File

@@ -46,7 +46,7 @@ func (h *HasherFunc) Combi(a [32]byte, b [32]byte) [32]byte {
// MixIn works like Combi, but using an integer as the second input.
func (h *HasherFunc) MixIn(a [32]byte, i uint64) [32]byte {
copy(h.b[:32], a[:])
copy(h.b[32:], make([]byte, 32, 32))
copy(h.b[32:], make([]byte, 32))
binary.LittleEndian.PutUint64(h.b[32:], i)
return h.Hash(h.b[:])
}

View File

@@ -83,7 +83,7 @@ func Merkleize(hasher Hasher, count uint64, limit uint64, leaf func(i uint64) []
}
depth := GetDepth(count)
limitDepth := GetDepth(limit)
tmp := make([][32]byte, limitDepth+1, limitDepth+1)
tmp := make([][32]byte, limitDepth+1)
j := uint8(0)
hArr := [32]byte{}
@@ -148,7 +148,7 @@ func ConstructProof(hasher Hasher, count uint64, limit uint64, leaf func(i uint6
limitDepth := GetDepth(limit)
branch = append(branch, trieutil.ZeroHashes[:limitDepth]...)
tmp := make([][32]byte, limitDepth+1, limitDepth+1)
tmp := make([][32]byte, limitDepth+1)
j := uint8(0)
hArr := [32]byte{}

View File

@@ -58,7 +58,7 @@ func GenerateTrieFromItems(items [][]byte, depth int) (*SparseMerkleTrie, error)
if len(layers[i])%2 == 1 {
layers[i] = append(layers[i], ZeroHashes[i][:])
}
updatedValues := make([][]byte, 0, 0)
updatedValues := make([][]byte, 0)
for j := 0; j < len(layers[i]); j += 2 {
concat := hashutil.Hash(append(layers[i][j], layers[i][j+1]...))
updatedValues = append(updatedValues, concat[:])

View File

@@ -64,7 +64,7 @@ func (s *MockSpanDetector) SpanForEpochByValidator(ctx context.Context, valIdx u
// ValidatorSpansByEpoch returns a list of all validator spans in a given epoch.
func (s *MockSpanDetector) ValidatorSpansByEpoch(ctx context.Context, epoch uint64) map[uint64]types.Span {
return make(map[uint64]types.Span, 0)
return make(map[uint64]types.Span)
}
// DeleteValidatorSpansByEpoch mocks the delete spans by epoch function.