Permalink
Browse files

container/heap: avoid up() invoke if down() success at heap.Remove()

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 ee57e36dfa6879c05ac6717c29f2df5b546e1256
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/container/heap/heap.go
@@ -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()
}

0 comments on commit ee57e36

Please sign in to comment.