mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: use iterator instead of raw node for treap find
Right now the mTreap structure exposes the treapNode structure through only one interface: find. There's no reason (performance or otherwise) for exposing this, and we get a cleaner abstraction through the iterators this way. This change also makes it easier to make changes to the mTreap implementation without violating its interface. Change-Id: I5ef86b8ac81a47d05d8404df65af9ec5f419dc40 Reviewed-on: https://go-review.googlesource.com/c/go/+/164098 Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
23d4c6cdd6
commit
7bb8fc1033
2 changed files with 12 additions and 12 deletions
|
|
@ -1126,12 +1126,12 @@ func (h *mheap) pickFreeSpan(npage uintptr) *mspan {
|
|||
// Note that we want the _smaller_ free span, i.e. the free span
|
||||
// closer in size to the amount we requested (npage).
|
||||
var s *mspan
|
||||
if tf != nil && (ts == nil || tf.spanKey.npages <= ts.spanKey.npages) {
|
||||
s = tf.spanKey
|
||||
h.free.removeNode(tf)
|
||||
} else if ts != nil && (tf == nil || tf.spanKey.npages > ts.spanKey.npages) {
|
||||
s = ts.spanKey
|
||||
h.scav.removeNode(ts)
|
||||
if tf.valid() && (!ts.valid() || tf.span().npages <= ts.span().npages) {
|
||||
s = tf.span()
|
||||
h.free.erase(tf)
|
||||
} else if ts.valid() && (!tf.valid() || tf.span().npages > ts.span().npages) {
|
||||
s = ts.span()
|
||||
h.scav.erase(ts)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue