mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
trie/bintrie: move ensureWritable into setValue
This commit is contained in:
parent
ee951bad21
commit
efc164b850
2 changed files with 1 additions and 3 deletions
|
|
@ -97,6 +97,7 @@ func (sn *StemNode) ensureWritable() {
|
|||
|
||||
// setValue sets or inserts a value at the given suffix.
|
||||
func (sn *StemNode) setValue(suffix byte, value []byte) {
|
||||
sn.ensureWritable()
|
||||
idx := int(suffix)
|
||||
pos := sn.posInData(suffix)
|
||||
if pos >= 0 {
|
||||
|
|
|
|||
|
|
@ -192,7 +192,6 @@ func (s *NodeStore) InsertSingle(stem []byte, suffix byte, value []byte, resolve
|
|||
if s.root.Kind() == KindStem {
|
||||
sn := s.getStem(s.root.Index())
|
||||
if sn.Stem == [StemSize]byte(stem[:StemSize]) {
|
||||
sn.ensureWritable()
|
||||
sn.setValue(suffix, value)
|
||||
sn.mustRecompute = true
|
||||
return nil
|
||||
|
|
@ -235,7 +234,6 @@ func (s *NodeStore) insertSingleInternal(stem []byte, suffix byte, value []byte,
|
|||
case KindStem:
|
||||
sn := s.getStem(cur.Index())
|
||||
if sn.Stem == [StemSize]byte(stem[:StemSize]) {
|
||||
sn.ensureWritable()
|
||||
sn.setValue(suffix, value)
|
||||
sn.mustRecompute = true
|
||||
return nil
|
||||
|
|
@ -432,7 +430,6 @@ func (s *NodeStore) insertValuesAtStem(ref NodeRef, stem []byte, values [][]byte
|
|||
sn := s.getStem(ref.Index())
|
||||
if sn.Stem == [StemSize]byte(stem[:StemSize]) {
|
||||
// Same stem — merge values
|
||||
sn.ensureWritable()
|
||||
for i, v := range values {
|
||||
if v != nil {
|
||||
sn.setValue(byte(i), v)
|
||||
|
|
|
|||
Loading…
Reference in a new issue