mirror of
https://github.com/golang/go
synced 2024-11-23 20:30:04 -07:00
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>
This commit is contained in:
parent
1fcd7861e3
commit
ee57e36dfa
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user