Skip to content

Commit 9a17ce9

Browse files
justinbayfjl
authored andcommitted
beacon/light: optimize database key assembling (ethereum#33292)
1 parent 4e61142 commit 9a17ce9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

beacon/light/canonical.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ func newCanonicalStore[T any](db ethdb.Iteratee, keyPrefix []byte) (*canonicalSt
6969

7070
// databaseKey returns the database key belonging to the given period.
7171
func (cs *canonicalStore[T]) databaseKey(period uint64) []byte {
72-
return binary.BigEndian.AppendUint64(append([]byte{}, cs.keyPrefix...), period)
72+
key := make([]byte, len(cs.keyPrefix)+8)
73+
copy(key, cs.keyPrefix)
74+
binary.BigEndian.PutUint64(key[len(cs.keyPrefix):], period)
75+
return key
7376
}
7477

7578
// add adds the given item to the database. It also ensures that the range remains

0 commit comments

Comments
 (0)