diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2015-01-28 08:42:20 +0300 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2015-01-28 20:37:20 +0000 |
commit | 4ce4d8b2c4ffb0378a246b26815e9e27d077670a (patch) | |
tree | 47a9ab04b5123b069d3f868be8590b14314cb18c /src/runtime/string.go | |
parent | e6fac08146df323eb95f46508bef937cdfb802fd (diff) | |
download | go-4ce4d8b2c4ffb0378a246b26815e9e27d077670a.tar.gz go-4ce4d8b2c4ffb0378a246b26815e9e27d077670a.zip |
cmd/gc: allocate stack buffer for ORUNESTR
If result of string(i) does not escape,
allocate a [4]byte temp on stack for it.
Change-Id: If31ce9447982929d5b3b963fd0830efae4247c37
Reviewed-on: https://go-review.googlesource.com/3411
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/string.go')
-rw-r--r-- | src/runtime/string.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/runtime/string.go b/src/runtime/string.go index 9ec6f320eb..58198d0e1b 100644 --- a/src/runtime/string.go +++ b/src/runtime/string.go @@ -185,8 +185,15 @@ type stringStruct struct { len int } -func intstring(v int64) string { - s, b := rawstring(4) +func intstring(buf *[4]byte, v int64) string { + var s string + var b []byte + if buf != nil { + b = buf[:] + s = slicebytetostringtmp(b) + } else { + s, b = rawstring(4) + } n := runetochar(b, rune(v)) return s[:n] } |