Skip to content

Commit

Permalink
Simplify array copying
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Nov 16, 2021
1 parent 07a0e53 commit 0bc4a88
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/trie/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,14 @@ func (b *branch) copy() node {
defer b.Unlock()
cpy := &branch{
key: make([]byte, len(b.key)),
children: [16]node{},
children: b.children, // copy interface pointers
value: nil,
dirty: b.dirty,
hash: make([]byte, len(b.hash)),
encoding: make([]byte, len(b.encoding)),
generation: b.generation,
}
copy(cpy.key, b.key)
copy(cpy.children[:], b.children[:]) // copy interface pointers

// nil and []byte{} are encoded differently, watch out!
if b.value != nil {
Expand Down

0 comments on commit 0bc4a88

Please sign in to comment.