Skip to content

Commit

Permalink
container/heap: avoid up() invoke if down() success at heap.Remove()
Browse files Browse the repository at this point in the history
Change-Id: I6c210e0c23ca533e1f303f88ef9dcb629a294a2a
Reviewed-on: https://go-review.googlesource.com/43472
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
  • Loading branch information
wuyunzhou authored and griesemer committed May 13, 2017
1 parent 1fcd786 commit ee57e36
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/container/heap/heap.go
Expand Up @@ -72,8 +72,9 @@ func Remove(h Interface, i int) interface{} {
n := h.Len() - 1
if n != i {
h.Swap(i, n)
down(h, i, n)
up(h, i)
if !down(h, i, n) {
up(h, i)
}
}
return h.Pop()
}
Expand Down

0 comments on commit ee57e36

Please sign in to comment.