From 695545b49b5fcf4398b878ac7100c20a0b799c2c Mon Sep 17 00:00:00 2001 From: rrhlrmrr Date: Tue, 8 Jul 2025 14:11:06 +0900 Subject: [PATCH] triedb: use sync pool --- triedb/pathdb/lookup.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/triedb/pathdb/lookup.go b/triedb/pathdb/lookup.go index 8b092730f8..45e5ab3375 100644 --- a/triedb/pathdb/lookup.go +++ b/triedb/pathdb/lookup.go @@ -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 @@ -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 @@ -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