From a584b07b231d88582a738987dbc4ea5f625b2308 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Tue, 20 Jan 2026 22:05:43 +0800 Subject: [PATCH] cmd/utils: prealloc + clear map --- cmd/utils/cmd.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index 3e337a3d00..abbdffbbc8 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -512,7 +512,7 @@ func ImportPreimages(db ethdb.Database, fn string) error { stream := rlp.NewStream(reader, 0) // Import the preimages in batches to prevent disk thrashing - preimages := make(map[common.Hash][]byte) + preimages := make(map[common.Hash][]byte, 1024) for { // Read the next entry and ensure it's not junk @@ -528,7 +528,7 @@ func ImportPreimages(db ethdb.Database, fn string) error { preimages[crypto.Keccak256Hash(blob)] = common.CopyBytes(blob) if len(preimages) > 1024 { rawdb.WritePreimages(db, preimages) - preimages = make(map[common.Hash][]byte) + clear(preimages) } } // Flush the last batch preimage data