mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-14 06:48:20 +00:00
trie: reduce allocs in insertPreimage (#21261)
This commit is contained in:
parent
20de87c1bf
commit
4d3004c152
@ -240,14 +240,15 @@ func (db *Database) InsertBlob(hash common.Hash, blob []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// insertPreimage writes a new trie node pre-image to the memory database if it's
|
// insertPreimage writes a new trie node pre-image to the memory database if it's
|
||||||
// yet unknown. The method will make a copy of the slice.
|
// yet unknown. The method will NOT make a copy of the slice,
|
||||||
|
// only use if the preimage will NOT be changed later on.
|
||||||
//
|
//
|
||||||
// Note, this method assumes that the database's lock is held!
|
// Note, this method assumes that the database's lock is held!
|
||||||
func (db *Database) insertPreimage(hash common.Hash, preimage []byte) {
|
func (db *Database) insertPreimage(hash common.Hash, preimage []byte) {
|
||||||
if _, ok := db.preimages[hash]; ok {
|
if _, ok := db.preimages[hash]; ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
db.preimages[hash] = common.CopyBytes(preimage)
|
db.preimages[hash] = preimage
|
||||||
db.preimagesSize += common.StorageSize(common.HashLength + len(preimage))
|
db.preimagesSize += common.StorageSize(common.HashLength + len(preimage))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user