mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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
1 changed files with 3 additions and 2 deletions
|
|
@ -72,9 +72,10 @@ func Remove(h Interface, i int) interface{} {
|
||||||
n := h.Len() - 1
|
n := h.Len() - 1
|
||||||
if n != i {
|
if n != i {
|
||||||
h.Swap(i, n)
|
h.Swap(i, n)
|
||||||
down(h, i, n)
|
if !down(h, i, n) {
|
||||||
up(h, i)
|
up(h, i)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return h.Pop()
|
return h.Pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue