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
diff --git a/src/pkg/runtime/panic.go b/src/pkg/runtime/panic.go
index ac0c6b7..9b95f49 100644
--- a/src/pkg/runtime/panic.go
+++ b/src/pkg/runtime/panic.go
@@ -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)
}