mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: use divRoundUp
There are a handful of places where the runtime wants to round up the result of a division. We just introduced a helper to do this. This CL replaces all of the hand-coded round-ups (that I could find) with this helper. Change-Id: I465d152157ff0f3cad40c0aa57491e4f2de510ad Reviewed-on: https://go-review.googlesource.com/c/go/+/224385 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
ab5a40c5e3
commit
d965bb6130
4 changed files with 6 additions and 6 deletions
|
|
@ -1035,9 +1035,9 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
|||
} else {
|
||||
var sizeclass uint8
|
||||
if size <= smallSizeMax-8 {
|
||||
sizeclass = size_to_class8[(size+smallSizeDiv-1)/smallSizeDiv]
|
||||
sizeclass = size_to_class8[divRoundUp(size, smallSizeDiv)]
|
||||
} else {
|
||||
sizeclass = size_to_class128[(size-smallSizeMax+largeSizeDiv-1)/largeSizeDiv]
|
||||
sizeclass = size_to_class128[divRoundUp(size-smallSizeMax, largeSizeDiv)]
|
||||
}
|
||||
size = uintptr(class_to_size[sizeclass])
|
||||
spc := makeSpanClass(sizeclass, noscan)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue