mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
trie/bintrie: inline get/InsertValuesAtStem wrappers
Gballet's three empty 'suggestion' blocks (comments 3101685618, 3101734697, 3101736436) mark the unexported wrapper declarations on getValuesAtStem and insertValuesAtStem plus one temporary-var line. Apply: - Inline the unexported getValuesAtStem body into GetValuesAtStem (start the walk at s.root directly instead of via a two-arg helper). The function is not self-recursive, so the wrapper was pure indirection. - Tighten InsertValuesAtStem to two lines using the 's.root, err = ...' idiom — the recursive helper stays (it IS self-recursive), only the public entry point gets the cleanup. Adds docstrings on both public entry points.
This commit is contained in:
parent
aa21cd1b80
commit
b86e2d3e20
1 changed files with 11 additions and 11 deletions
|
|
@ -38,12 +38,11 @@ func (s *NodeStore) GetValue(stem []byte, suffix byte, resolver NodeResolverFn)
|
|||
return values[suffix], nil
|
||||
}
|
||||
|
||||
// GetValuesAtStem returns the 256 value slots at stem, or nil if the stem
|
||||
// is not in the trie. The returned slice is a view over the in-place
|
||||
// StemNode values array (no allocation) and must be treated read-only.
|
||||
func (s *NodeStore) GetValuesAtStem(stem []byte, resolver NodeResolverFn) ([][]byte, error) {
|
||||
return s.getValuesAtStem(s.root, stem, resolver)
|
||||
}
|
||||
|
||||
func (s *NodeStore) getValuesAtStem(ref nodeRef, stem []byte, resolver NodeResolverFn) ([][]byte, error) {
|
||||
cur := ref
|
||||
cur := s.root
|
||||
var parentIdx uint32
|
||||
var parentIsLeft bool
|
||||
|
||||
|
|
@ -125,13 +124,14 @@ func (s *NodeStore) InsertSingle(stem []byte, suffix byte, value []byte, resolve
|
|||
return s.InsertValuesAtStem(stem, values[:], resolver)
|
||||
}
|
||||
|
||||
// InsertValuesAtStem writes the supplied value slots at stem. values may be
|
||||
// sparse (nil entries are ignored). The recursive implementation dispatches
|
||||
// through the same body, so a single code path handles internal descent,
|
||||
// HashedNode resolution, stem merge, and stem split.
|
||||
func (s *NodeStore) InsertValuesAtStem(stem []byte, values [][]byte, resolver NodeResolverFn) error {
|
||||
newRoot, err := s.insertValuesAtStem(s.root, stem, values, resolver, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.root = newRoot
|
||||
return nil
|
||||
var err error
|
||||
s.root, err = s.insertValuesAtStem(s.root, stem, values, resolver, 0)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *NodeStore) insertValuesAtStem(ref nodeRef, stem []byte, values [][]byte, resolver NodeResolverFn, depth int) (nodeRef, error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue