Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions triedb/pathdb/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import (
"golang.org/x/sync/errgroup"
)

var hashSlicePool = sync.Pool{
New: func() interface{} {
return make([]common.Hash, 0, 16)
},
}

// storageKey returns a key for uniquely identifying the storage slot.
func storageKey(accountHash common.Hash, slotHash common.Hash) [64]byte {
var key [64]byte
Expand Down Expand Up @@ -182,7 +188,7 @@ func (l *lookup) addLayer(diff *diffLayer) {
for accountHash := range diff.states.accountData {
list, exists := l.accounts[accountHash]
if !exists {
list = make([]common.Hash, 0, 16) // TODO(rjl493456442) use sync pool
list = hashSlicePool.Get().([]common.Hash)
}
list = append(list, state)
l.accounts[accountHash] = list
Expand All @@ -197,7 +203,7 @@ func (l *lookup) addLayer(diff *diffLayer) {
key := storageKey(accountHash, slotHash)
list, exists := l.storages[key]
if !exists {
list = make([]common.Hash, 0, 16) // TODO(rjl493456442) use sync pool
list = hashSlicePool.Get().([]common.Hash)
}
list = append(list, state)
l.storages[key] = list
Expand Down
Loading