Commit 011b8eb6 authored by Austin Clements's avatar Austin Clements

runtime: don't double-zero treap nodes

mheap_.treapalloc.alloc() already returns a zeroed treapNode. Don't
bother re-zeroing all of the fields.

Change-Id: Iea317040fbb72dfe5ef1e2c56c287680b065f2d9
Reviewed-on: https://go-review.googlesource.com/c/139460
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 6606cd3d
......@@ -46,15 +46,6 @@ type treapNode struct {
priority uint32 // random number used by treap algorithm to keep tree probabilistically balanced
}
func (t *treapNode) init() {
t.right = nil
t.left = nil
t.parent = nil
t.spanKey = nil
t.npagesKey = 0
t.priority = 0
}
// isSpanInTreap is handy for debugging. One should hold the heap lock, usually
// mheap_.lock().
func (t *treapNode) isSpanInTreap(s *mspan) bool {
......@@ -140,7 +131,6 @@ func (root *mTreap) insert(span *mspan) {
// https://faculty.washington.edu/aragon/pubs/rst89.pdf
t := (*treapNode)(mheap_.treapalloc.alloc())
t.init()
t.npagesKey = span.npages
t.priority = fastrand()
t.spanKey = span
......@@ -188,8 +178,6 @@ func (root *mTreap) removeNode(t *treapNode) {
root.treap = nil
}
// Return the found treapNode's span after freeing the treapNode.
t.spanKey = nil
t.npagesKey = 0
mheap_.treapalloc.free(unsafe.Pointer(t))
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment