aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-08-30 14:18:41 -0400
committerRuss Cox <rsc@golang.org>2014-08-30 14:18:41 -0400
commit7006aafdcd3be55d13e987dc9008425111bc7850 (patch)
tree5b563d28f8504cc2099282908492414bd2e4106c /src/pkg/runtime
parent47d6af2f68d43d496f7155d705f269b126f8f108 (diff)
downloadgo-7006aafdcd3be55d13e987dc9008425111bc7850.tar.xz
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
Diffstat (limited to 'src/pkg/runtime')
-rw-r--r--src/pkg/runtime/panic.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pkg/runtime/panic.go b/src/pkg/runtime/panic.go
index ac0c6b77ee..9b95f49673 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)
}