]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: don't double-zero treap nodes
authorAustin Clements <austin@google.com>
Fri, 30 Jun 2017 16:18:27 +0000 (12:18 -0400)
committerAustin Clements <austin@google.com>
Thu, 4 Oct 2018 16:14:16 +0000 (16:14 +0000)
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: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/mgclarge.go

index e7fa831937aca0e7235397b3f3ea29878bf99b53..11a977d6bad1e6780bfa3222931ef339ee39901c 100644 (file)
@@ -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))
 }