Skip to content

Commit

Permalink
Remove const for return mutated values
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Sep 30, 2022
1 parent 5fed227 commit a3d9357
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ func (t *Trie) Put(keyLE, value []byte) {
func (t *Trie) insert(parent *Node, key, value []byte) (
newParent *Node, mutated bool, nodesCreated uint32) {
if parent == nil {
const nodesCreated = 1
const mutated = true
mutated = true
nodesCreated = 1
return &Node{
Key: key,
SubValue: value,
Expand All @@ -354,15 +354,15 @@ func (t *Trie) insertInLeaf(parentLeaf *Node, key, value []byte) (
if bytes.Equal(parentLeaf.Key, key) {
nodesCreated = 0
if parentLeaf.SubValueEqual(value) {
const mutated = false
mutated = false
return parentLeaf, mutated, nodesCreated
}

copySettings := node.DefaultCopySettings
copySettings.CopyValue = false
parentLeaf = t.prepLeafForMutation(parentLeaf, copySettings)
parentLeaf.SubValue = value
const mutated = true
mutated = true
return parentLeaf, mutated, nodesCreated
}

Expand Down Expand Up @@ -434,12 +434,12 @@ func (t *Trie) insertInBranch(parentBranch *Node, key, value []byte) (

if bytes.Equal(key, parentBranch.Key) {
if parentBranch.SubValueEqual(value) {
const mutated = false
mutated = false
return parentBranch, mutated, 0
}
parentBranch = t.prepBranchForMutation(parentBranch, copySettings)
parentBranch.SubValue = value
const mutated = true
mutated = true
return parentBranch, mutated, 0
}

Expand All @@ -457,11 +457,11 @@ func (t *Trie) insertInBranch(parentBranch *Node, key, value []byte) (
Generation: t.generation,
Dirty: true,
}
nodesCreated = 1
parentBranch = t.prepBranchForMutation(parentBranch, copySettings)
parentBranch.Children[childIndex] = child
parentBranch.Descendants += nodesCreated
const mutated = true
mutated = true
nodesCreated = 1
return parentBranch, mutated, nodesCreated
}

Expand Down

0 comments on commit a3d9357

Please sign in to comment.