Skip to content

Commit

Permalink
Reverse logic of if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
iand committed Oct 18, 2023
1 parent eafbb6c commit 4ade049
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kad/trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ func addAtDepth[K kad.Key[K], D any](depth int, tr *Trie[K, D], kk K, data D) *T
default:
dir := kk.Bit(depth)
b := addAtDepth(depth+1, tr.branch[dir], kk, data)
if b != tr.branch[dir] {
s := &Trie[K, D]{}
s.branch[dir] = b
s.branch[1-dir] = tr.branch[1-dir]
return s
if b == tr.branch[dir] {
return tr
}
return tr
s := &Trie[K, D]{}
s.branch[dir] = b
s.branch[1-dir] = tr.branch[1-dir]
return s
}
}

Expand Down

0 comments on commit 4ade049

Please sign in to comment.