diff options
author | Austin Clements <austin@google.com> | 2020-03-20 11:37:54 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2020-03-20 16:05:35 +0000 |
commit | d965bb613086cd780cf73418bcdeaef50a9afc55 (patch) | |
tree | d57632acdcb73de11dafae0b3db55d58fd9cb2ae /src/runtime/msize.go | |
parent | ab5a40c5e3162a565b26de4b1e7595f7922ba761 (diff) | |
download | go-d965bb613086cd780cf73418bcdeaef50a9afc55.tar.gz go-d965bb613086cd780cf73418bcdeaef50a9afc55.zip |
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>
Diffstat (limited to 'src/runtime/msize.go')
-rw-r--r-- | src/runtime/msize.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/runtime/msize.go b/src/runtime/msize.go index 11d06ce025..c56aa5a7b2 100644 --- a/src/runtime/msize.go +++ b/src/runtime/msize.go @@ -13,9 +13,9 @@ package runtime func roundupsize(size uintptr) uintptr { if size < _MaxSmallSize { if size <= smallSizeMax-8 { - return uintptr(class_to_size[size_to_class8[(size+smallSizeDiv-1)/smallSizeDiv]]) + return uintptr(class_to_size[size_to_class8[divRoundUp(size, smallSizeDiv)]]) } else { - return uintptr(class_to_size[size_to_class128[(size-smallSizeMax+largeSizeDiv-1)/largeSizeDiv]]) + return uintptr(class_to_size[size_to_class128[divRoundUp(size-smallSizeMax, largeSizeDiv)]]) } } if size+_PageSize < size { |