Commit 7006aafd authored by Russ Cox's avatar Russ Cox

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
parent 47d6af2f
...@@ -4,10 +4,14 @@ ...@@ -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)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment