From 994b4b4be458d80eb3a8a79c2bceaa6e2561b62e Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Wed, 27 Mar 2024 16:48:44 +0800 Subject: [PATCH] core: using slices.Clone to simplify codes --- core/state/statedb.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 981eea7d6f92..8cdcbc40c32c 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -20,6 +20,7 @@ package state import ( "fmt" "math/big" + "slices" "sort" "time" @@ -243,9 +244,7 @@ func (s *StateDB) Logs() []*types.Log { func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) { if _, ok := s.preimages[hash]; !ok { s.journal.append(addPreimageChange{hash: hash}) - pi := make([]byte, len(preimage)) - copy(pi, preimage) - s.preimages[hash] = pi + s.preimages[hash] = slices.Clone(preimage) } }