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
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)
}