1
0
mirror of https://github.com/golang/go synced 2024-10-02 18:18:33 -06: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:
Russ Cox 2014-08-30 14:18:41 -04:00
parent 47d6af2f68
commit 7006aafdcd

View File

@ -4,10 +4,14 @@
package runtime
var indexError = error(errorString("index out of range"))
func panicindex() {
panic(errorString("index out of range"))
panic(indexError)
}
var sliceError = error(errorString("slice bounds out of range"))
func panicslice() {
panic(errorString("slice bounds out of range"))
panic(sliceError)
}