From: Austin Clements Date: Mon, 6 Feb 2017 00:34:16 +0000 (-0500) Subject: runtime: clarify access to mheap_.busy X-Git-Tag: go1.9beta1~1322 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=77f64c50dbaca5fcec8198a575f6c345cb80ad69;p=gostls13.git runtime: clarify access to mheap_.busy There are two accesses to mheap_.busy that are guarded by checks against len(mheap_.free). This works because both lists are (and must be) the same length, but it makes the code less clear. Change these to use len(mheap_.busy) so the access more clearly parallels the check. Fixes #18944. Change-Id: I9bacbd3663988df351ed4396ae9018bc71018311 Reviewed-on: https://go-review.googlesource.com/36354 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Rick Hudson --- diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index ef62eff6da..650a6d1a9c 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -589,7 +589,7 @@ func (h *mheap) alloc_m(npage uintptr, sizeclass int32, large bool) *mspan { memstats.heap_objects++ atomic.Xadd64(&memstats.heap_live, int64(npage<<_PageShift)) // Swept spans are at the end of lists. - if s.npages < uintptr(len(h.free)) { + if s.npages < uintptr(len(h.busy)) { h.busy[s.npages].insertBack(s) } else { h.busylarge.insertBack(s) @@ -941,7 +941,7 @@ func (h *mheap) freeList(npages uintptr) *mSpanList { } func (h *mheap) busyList(npages uintptr) *mSpanList { - if npages < uintptr(len(h.free)) { + if npages < uintptr(len(h.busy)) { return &h.busy[npages] } return &h.busylarge