Skip to content

Commit d1922f6

Browse files
committed
core, trie: polish
1 parent e6938d0 commit d1922f6

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"
@@ -471,7 +472,7 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
471472
// always creates a new slice) instead of append to
472473
// avoid modifying n.Key since it might be shared with
473474
// other nodes.
474-
return true, &shortNode{concat(n.Key, child.Key...), child.Val, t.newFlag()}, nil
475+
return true, &shortNode{slices.Concat(n.Key, child.Key...), child.Val, t.newFlag()}, nil
475476
default:
476477
return true, &shortNode{n.Key, child, t.newFlag()}, nil
477478
}
@@ -566,13 +567,6 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
566567
}
567568
}
568569

569-
func concat(s1 []byte, s2 ...byte) []byte {
570-
r := make([]byte, len(s1)+len(s2))
571-
copy(r, s1)
572-
copy(r[len(s1):], s2)
573-
return r
574-
}
575-
576570
// copyNode deep-copies the supplied node along with its children recursively.
577571
func copyNode(n node) node {
578572
switch n := (n).(type) {

0 commit comments

Comments
 (0)