Skip to content

Commit 6427923

Browse files
committed
runtime: remove unused maxSliceCap function and maxElems array
All uses of these have been converted to use runtime/internal/math functions for overflow checking. Fixes #21588 Change-Id: I0ba57028e471803dc7d445e66d77a8f87edfdafb Reviewed-on: https://go-review.googlesource.com/c/144037 Run-TryBot: Martin Möhrmann <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 1e50dd0 commit 6427923

File tree

2 files changed

+0
-23
lines changed

2 files changed

+0
-23
lines changed

src/cmd/compile/internal/gc/inl_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func TestIntendedInlining(t *testing.T) {
5454
"getm",
5555
"isDirectIface",
5656
"itabHashFunc",
57-
"maxSliceCap",
5857
"noescape",
5958
"readUnaligned32",
6059
"readUnaligned64",

src/runtime/slice.go

-22
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,6 @@ type notInHeapSlice struct {
2323
cap int
2424
}
2525

26-
// maxElems is a lookup table containing the maximum capacity for a slice.
27-
// The index is the size of the slice element.
28-
var maxElems = [...]uintptr{
29-
^uintptr(0),
30-
maxAlloc / 1, maxAlloc / 2, maxAlloc / 3, maxAlloc / 4,
31-
maxAlloc / 5, maxAlloc / 6, maxAlloc / 7, maxAlloc / 8,
32-
maxAlloc / 9, maxAlloc / 10, maxAlloc / 11, maxAlloc / 12,
33-
maxAlloc / 13, maxAlloc / 14, maxAlloc / 15, maxAlloc / 16,
34-
maxAlloc / 17, maxAlloc / 18, maxAlloc / 19, maxAlloc / 20,
35-
maxAlloc / 21, maxAlloc / 22, maxAlloc / 23, maxAlloc / 24,
36-
maxAlloc / 25, maxAlloc / 26, maxAlloc / 27, maxAlloc / 28,
37-
maxAlloc / 29, maxAlloc / 30, maxAlloc / 31, maxAlloc / 32,
38-
}
39-
40-
// maxSliceCap returns the maximum capacity for a slice.
41-
func maxSliceCap(elemsize uintptr) uintptr {
42-
if elemsize < uintptr(len(maxElems)) {
43-
return maxElems[elemsize]
44-
}
45-
return maxAlloc / elemsize
46-
}
47-
4826
func panicmakeslicelen() {
4927
panic(errorString("makeslice: len out of range"))
5028
}

0 commit comments

Comments
 (0)