Skip to content

Commit ca8c82e

Browse files
committed
core, trie: polish
1 parent 3b35457 commit ca8c82e

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

core/stateless/database.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,5 @@ func (w *Witness) MakeHashDB() ethdb.Database {
6363

6464
rawdb.WriteLegacyTrieNode(memdb, common.BytesToHash(hash), blob)
6565
}
66-
6766
return memdb
6867
}

core/stateless/stats.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ func newDepthStats() *depthStats {
4646
return &depthStats{minDepth: -1}
4747
}
4848

49-
// Add records a new depth sample.
50-
func (d *depthStats) Add(n int64) {
49+
// add records a new depth sample.
50+
func (d *depthStats) add(n int64) {
5151
if n < 0 {
5252
return
5353
}
@@ -92,11 +92,11 @@ func NewWitnessStats() *WitnessStats {
9292
func (s *WitnessStats) Add(nodes map[string][]byte, owner common.Hash) {
9393
if owner == (common.Hash{}) {
9494
for path := range maps.Keys(nodes) {
95-
s.accountTrie.Add(int64(len(path)))
95+
s.accountTrie.add(int64(len(path)))
9696
}
9797
} else {
9898
for path := range maps.Keys(nodes) {
99-
s.storageTrie.Add(int64(len(path)))
99+
s.storageTrie.add(int64(len(path)))
100100
}
101101
}
102102
}

trie/trie.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"bytes"
2222
"errors"
2323
"fmt"
24+
"slices"
2425

2526
"github.com/ethereum/go-ethereum/common"
2627
"github.com/ethereum/go-ethereum/core/types"
@@ -517,7 +518,7 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
517518
// always creates a new slice) instead of append to
518519
// avoid modifying n.Key since it might be shared with
519520
// other nodes.
520-
return true, &shortNode{concat(n.Key, child.Key...), child.Val, t.newFlag()}, nil
521+
return true, &shortNode{slices.Concat(n.Key, child.Key...), child.Val, t.newFlag()}, nil
521522
default:
522523
return true, &shortNode{n.Key, child, t.newFlag()}, nil
523524
}
@@ -612,13 +613,6 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
612613
}
613614
}
614615

615-
func concat(s1 []byte, s2 ...byte) []byte {
616-
r := make([]byte, len(s1)+len(s2))
617-
copy(r, s1)
618-
copy(r[len(s1):], s2)
619-
return r
620-
}
621-
622616
// copyNode deep-copies the supplied node along with its children recursively.
623617
func copyNode(n node) node {
624618
switch n := (n).(type) {

0 commit comments

Comments
 (0)