mirror of
https://github.com/golang/go
synced 2024-11-19 22:04:44 -07:00
runtime: preallocate panic errors for index and slice
This avoids allocating at the panic sites. LGTM=r, khr R=golang-codereviews, r, khr CC=dvyukov, golang-codereviews, iant, khr https://golang.org/cl/136020043
This commit is contained in:
parent
47d6af2f68
commit
7006aafdcd
@ -4,10 +4,14 @@
|
|||||||
|
|
||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
|
var indexError = error(errorString("index out of range"))
|
||||||
|
|
||||||
func panicindex() {
|
func panicindex() {
|
||||||
panic(errorString("index out of range"))
|
panic(indexError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sliceError = error(errorString("slice bounds out of range"))
|
||||||
|
|
||||||
func panicslice() {
|
func panicslice() {
|
||||||
panic(errorString("slice bounds out of range"))
|
panic(sliceError)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user