@@ -21,7 +21,6 @@ import (
2121 "bytes"
2222 "errors"
2323 "fmt"
24- "slices"
2524
2625 "github.com/ethereum/go-ethereum/common"
2726 "github.com/ethereum/go-ethereum/core/types"
@@ -330,10 +329,6 @@ func (t *Trie) update(key, value []byte) error {
330329
331330func (t * Trie ) insert (n node , prefix , key []byte , value node ) (bool , node , error ) {
332331 if len (key ) == 0 {
333- if t .owner == (common.Hash {}) {
334- stateDepthAggregator .record (int64 (len (prefix )))
335- }
336-
337332 if v , ok := n .(valueNode ); ok {
338333 return ! bytes .Equal (v , value .(valueNode )), value , nil
339334 }
@@ -476,7 +471,10 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
476471 // always creates a new slice) instead of append to
477472 // avoid modifying n.Key since it might be shared with
478473 // other nodes.
479- return true , & shortNode {slices .Concat (n .Key , child .Key ), child .Val , t .newFlag ()}, nil
474+ if t .owner == (common.Hash {}) {
475+ stateDepthAggregator .record (int64 (len (prefix ) + len (key )))
476+ }
477+ return true , & shortNode {concat (n .Key , child .Key ... ), child .Val , t .newFlag ()}, nil
480478 default :
481479 return true , & shortNode {n .Key , child , t .newFlag ()}, nil
482480 }
@@ -533,7 +531,10 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
533531 // Replace the entire full node with the short node.
534532 // Mark the original short node as deleted since the
535533 // value is embedded into the parent now.
536- t .opTracer .onDelete (append (prefix , byte (pos )))
534+ t .tracer .onDelete (append (prefix , byte (pos )))
535+ if t .owner == (common.Hash {}) {
536+ stateDepthAggregator .record (int64 (len (prefix ) + 1 ))
537+ }
537538
538539 k := append ([]byte {byte (pos )}, cnode .Key ... )
539540 return true , & shortNode {k , cnode .Val , t .newFlag ()}, nil
0 commit comments