mirror of
https://github.com/golang/go.git
synced 2026-02-07 02:09:55 +00:00
internal/runtime: cleaner overflow checker
remove todo
Change-Id: I4b10d7a8c26bea9296b321f53abd0330f2afc35a
GitHub-Last-Rev: b939acc287
GitHub-Pull-Request: golang/go#74943
Reviewed-on: https://go-review.googlesource.com/c/go/+/694236
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
3871c0d84d
commit
052fcde9fd
2 changed files with 3 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ package maps
|
|||
import (
|
||||
"internal/abi"
|
||||
"internal/goarch"
|
||||
"internal/runtime/math"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
|
|
@ -127,8 +128,7 @@ func (t *table) maxGrowthLeft() uint16 {
|
|||
// single-group tables, we could fill all slots.
|
||||
return t.capacity - 1
|
||||
} else {
|
||||
if t.capacity*maxAvgGroupLoad < t.capacity {
|
||||
// TODO(prattmic): Do something cleaner.
|
||||
if t.capacity > math.MaxUint16/maxAvgGroupLoad {
|
||||
panic("overflow")
|
||||
}
|
||||
return (t.capacity * maxAvgGroupLoad) / abi.MapGroupSlots
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ package math
|
|||
import "internal/goarch"
|
||||
|
||||
const (
|
||||
MaxUint16 = ^uint16(0)
|
||||
MaxUint32 = ^uint32(0)
|
||||
MaxUint64 = ^uint64(0)
|
||||
MaxUintptr = ^uintptr(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue