Skip to content

Commit 8be715f

Browse files
gijswijsguggero
authored andcommitted
asset: init slice with both capacity and length
1 parent 0ff8849 commit 8be715f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

asset/encoding.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ func AltLeavesDecoder(r io.Reader, val any, buf *[8]byte, l uint64) error {
864864
return err
865865
}
866866

867-
leaves := make([]AltLeaf[Asset], 0, numItems)
867+
leaves := make([]AltLeaf[Asset], numItems)
868868
leafKeys := make(map[SerializedKey]struct{})
869869
for i := uint64(0); i < numItems; i++ {
870870
var streamBytes []byte
@@ -890,7 +890,7 @@ func AltLeavesDecoder(r io.Reader, val any, buf *[8]byte, l uint64) error {
890890
}
891891

892892
leafKeys[leafKey] = struct{}{}
893-
leaves = append(leaves, AltLeaf[Asset](&leaf))
893+
leaves[i] = AltLeaf[Asset](&leaf)
894894
}
895895

896896
*typ = leaves

0 commit comments

Comments
 (0)