aboutsummaryrefslogtreecommitdiffstats
path: root/les/randselect.go
diff options
context:
space:
mode:
authorGagziW <leon.stanko@rwth-aachen.de>2018-05-03 16:35:06 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-05-03 16:35:06 +0800
commit7c02933275d8f67fbdf78cdc05c0e09af4ebc657 (patch)
tree0f22379f2b9cb4d2c8731c570409c2b191a1603d /les/randselect.go
parentf2447bd4c35573d40e2ef678809657c5a1d4e999 (diff)
downloadgo-tangerine-7c02933275d8f67fbdf78cdc05c0e09af4ebc657.tar
go-tangerine-7c02933275d8f67fbdf78cdc05c0e09af4ebc657.tar.gz
go-tangerine-7c02933275d8f67fbdf78cdc05c0e09af4ebc657.tar.bz2
go-tangerine-7c02933275d8f67fbdf78cdc05c0e09af4ebc657.tar.lz
go-tangerine-7c02933275d8f67fbdf78cdc05c0e09af4ebc657.tar.xz
go-tangerine-7c02933275d8f67fbdf78cdc05c0e09af4ebc657.tar.zst
go-tangerine-7c02933275d8f67fbdf78cdc05c0e09af4ebc657.zip
les: changed if-else blocks to conform with golint (#16658)
Diffstat (limited to 'les/randselect.go')
-rw-r--r--les/randselect.go23
1 files changed, 10 insertions, 13 deletions
diff --git a/les/randselect.go b/les/randselect.go
index 1a9d0695b..1cc1d3d3e 100644
--- a/les/randselect.go
+++ b/les/randselect.go
@@ -118,17 +118,16 @@ func (n *wrsNode) insert(item wrsItem, weight int64) int {
if n.level == 0 {
n.items[branch] = item
return branch
+ }
+ var subNode *wrsNode
+ if n.items[branch] == nil {
+ subNode = &wrsNode{maxItems: n.maxItems / wrsBranches, level: n.level - 1}
+ n.items[branch] = subNode
} else {
- var subNode *wrsNode
- if n.items[branch] == nil {
- subNode = &wrsNode{maxItems: n.maxItems / wrsBranches, level: n.level - 1}
- n.items[branch] = subNode
- } else {
- subNode = n.items[branch].(*wrsNode)
- }
- subIdx := subNode.insert(item, weight)
- return subNode.maxItems*branch + subIdx
+ subNode = n.items[branch].(*wrsNode)
}
+ subIdx := subNode.insert(item, weight)
+ return subNode.maxItems*branch + subIdx
}
// setWeight updates the weight of a certain item (which should exist) and returns
@@ -162,12 +161,10 @@ func (n *wrsNode) choose(val int64) (wrsItem, int64) {
if val < w {
if n.level == 0 {
return n.items[i].(wrsItem), n.weights[i]
- } else {
- return n.items[i].(*wrsNode).choose(val)
}
- } else {
- val -= w
+ return n.items[i].(*wrsNode).choose(val)
}
+ val -= w
}
panic(nil)
}