From: Russ Cox Date: Sat, 30 Aug 2014 18:18:41 +0000 (-0400) Subject: runtime: preallocate panic errors for index and slice X-Git-Tag: go1.4beta1~605 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7006aafdcd3be55d13e987dc9008425111bc7850;p=gostls13.git 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 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) }