Skip to content

Commit 33105f1

Browse files
authored
Simplify make call by omitting redundant arguments (#6949)
* removed redundant args * Merge refs/heads/master into omit-redundant-make-args
1 parent 44f9d07 commit 33105f1

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

beacon-chain/core/helpers/shuffle.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ func ComputeShuffledIndex(index uint64, indexCount uint64, seed [32]byte, shuffl
8383
// effectively un-shuffling the list.
8484
round = rounds - 1
8585
}
86-
buf := make([]byte, totalSize, totalSize)
87-
posBuffer := make([]byte, 8, 8)
86+
buf := make([]byte, totalSize)
87+
posBuffer := make([]byte, 8)
8888
hashfunc := hashutil.CustomSHA256Hasher()
8989

9090
// 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
168168
return input, nil
169169
}
170170
listSize := uint64(len(input))
171-
buf := make([]byte, totalSize, totalSize)
171+
buf := make([]byte, totalSize)
172172
r := uint8(0)
173173
if !shuffle {
174174
r = rounds - 1

beacon-chain/core/helpers/shuffle_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func BenchmarkShuffleList(b *testing.B) {
110110
listSizes := []uint64{400000, 40000, 400}
111111
seed := [32]byte{123, 42}
112112
for _, listSize := range listSizes {
113-
testIndices := make([]uint64, listSize, listSize)
113+
testIndices := make([]uint64, listSize)
114114
for i := uint64(0); i < listSize; i++ {
115115
testIndices[i] = i
116116
}

beacon-chain/core/helpers/spectest/shuffle_yaml_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func runShuffleTest(testCase *ShuffleTestCase) error {
5050
}
5151

5252
seed := common.BytesToHash(baseSeed)
53-
testIndices := make([]uint64, testCase.Count, testCase.Count)
53+
testIndices := make([]uint64, testCase.Count)
5454
for i := uint64(0); i < testCase.Count; i++ {
5555
testIndices[i] = i
5656
}

beacon-chain/rpc/beacon/attestations_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ func TestServer_ListAttestations_Pagination_DefaultPageSize(t *testing.T) {
521521

522522
func TestServer_mapAttestationToTargetRoot(t *testing.T) {
523523
count := uint64(100)
524-
atts := make([]*ethpb.Attestation, count, count)
524+
atts := make([]*ethpb.Attestation, count)
525525
targetRoot1 := bytesutil.ToBytes32([]byte("root1"))
526526
targetRoot2 := bytesutil.ToBytes32([]byte("root2"))
527527

@@ -606,7 +606,7 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) {
606606
state, _ := testutil.DeterministicGenesisState(t, numValidators)
607607

608608
// Next up we convert the test attestations to indexed form:
609-
indexedAtts := make([]*ethpb.IndexedAttestation, len(atts)+len(atts2), len(atts)+len(atts2))
609+
indexedAtts := make([]*ethpb.IndexedAttestation, len(atts)+len(atts2))
610610
for i := 0; i < len(atts); i++ {
611611
att := atts[i]
612612
committee, err := helpers.BeaconCommitteeFromState(state, att.Data.Slot, att.Data.CommitteeIndex)
@@ -707,7 +707,7 @@ func TestServer_ListIndexedAttestations_OldEpoch(t *testing.T) {
707707
require.NoError(t, state.SetSlot(startSlot))
708708

709709
// Next up we convert the test attestations to indexed form:
710-
indexedAtts := make([]*ethpb.IndexedAttestation, len(atts), len(atts))
710+
indexedAtts := make([]*ethpb.IndexedAttestation, len(atts))
711711
for i := 0; i < len(atts); i++ {
712712
att := atts[i]
713713
committee, err := helpers.BeaconCommitteeFromState(state, att.Data.Slot, att.Data.CommitteeIndex)

beacon-chain/state/stateutil/arrays.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func merkleizeTrieLeaves(layers [][][32]byte, hashLayer [][32]byte,
122122
chunkBuffer := bytes.NewBuffer([]byte{})
123123
chunkBuffer.Grow(64)
124124
for len(hashLayer) > 1 && i < len(layers) {
125-
layer := make([][32]byte, len(hashLayer)/2, len(hashLayer)/2)
125+
layer := make([][32]byte, len(hashLayer)/2)
126126
for j := 0; j < len(hashLayer); j += 2 {
127127
chunkBuffer.Write(hashLayer[j][:])
128128
chunkBuffer.Write(hashLayer[j+1][:])

shared/htrutils/hashers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (h *HasherFunc) Combi(a [32]byte, b [32]byte) [32]byte {
4646
// MixIn works like Combi, but using an integer as the second input.
4747
func (h *HasherFunc) MixIn(a [32]byte, i uint64) [32]byte {
4848
copy(h.b[:32], a[:])
49-
copy(h.b[32:], make([]byte, 32, 32))
49+
copy(h.b[32:], make([]byte, 32))
5050
binary.LittleEndian.PutUint64(h.b[32:], i)
5151
return h.Hash(h.b[:])
5252
}

shared/htrutils/merkleize.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func Merkleize(hasher Hasher, count uint64, limit uint64, leaf func(i uint64) []
8383
}
8484
depth := GetDepth(count)
8585
limitDepth := GetDepth(limit)
86-
tmp := make([][32]byte, limitDepth+1, limitDepth+1)
86+
tmp := make([][32]byte, limitDepth+1)
8787

8888
j := uint8(0)
8989
hArr := [32]byte{}
@@ -148,7 +148,7 @@ func ConstructProof(hasher Hasher, count uint64, limit uint64, leaf func(i uint6
148148
limitDepth := GetDepth(limit)
149149
branch = append(branch, trieutil.ZeroHashes[:limitDepth]...)
150150

151-
tmp := make([][32]byte, limitDepth+1, limitDepth+1)
151+
tmp := make([][32]byte, limitDepth+1)
152152

153153
j := uint8(0)
154154
hArr := [32]byte{}

shared/trieutil/sparse_merkle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func GenerateTrieFromItems(items [][]byte, depth int) (*SparseMerkleTrie, error)
5858
if len(layers[i])%2 == 1 {
5959
layers[i] = append(layers[i], ZeroHashes[i][:])
6060
}
61-
updatedValues := make([][]byte, 0, 0)
61+
updatedValues := make([][]byte, 0)
6262
for j := 0; j < len(layers[i]); j += 2 {
6363
concat := hashutil.Hash(append(layers[i][j], layers[i][j+1]...))
6464
updatedValues = append(updatedValues, concat[:])

slasher/detection/attestations/mock_spanner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (s *MockSpanDetector) SpanForEpochByValidator(ctx context.Context, valIdx u
6464

6565
// ValidatorSpansByEpoch returns a list of all validator spans in a given epoch.
6666
func (s *MockSpanDetector) ValidatorSpansByEpoch(ctx context.Context, epoch uint64) map[uint64]types.Span {
67-
return make(map[uint64]types.Span, 0)
67+
return make(map[uint64]types.Span)
6868
}
6969

7070
// DeleteValidatorSpansByEpoch mocks the delete spans by epoch function.

0 commit comments

Comments
 (0)