diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2018-04-30 23:05:41 -0700 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2018-05-01 18:03:57 +0000 |
commit | 2f2e8f9c81d899d8eefb1f2f98ce5c90976c4f61 (patch) | |
tree | a1a515847c66a63dc1b202ca43b2b6bed719a8fe /src/runtime/string.go | |
parent | 6a8cff57309ba3168844640b2da2ea3103d594fd (diff) | |
download | go-2f2e8f9c81d899d8eefb1f2f98ce5c90976c4f61.tar.gz go-2f2e8f9c81d899d8eefb1f2f98ce5c90976c4f61.zip |
runtime: use staticbytes in intstring for small v
Triggers 21 times during make.bash.
Change-Id: I7efb34200439256151304bb66cd309913f7c9c9e
Reviewed-on: https://go-review.googlesource.com/110557
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/string.go')
-rw-r--r-- | src/runtime/string.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/runtime/string.go b/src/runtime/string.go index 31518aed70..6e42483b13 100644 --- a/src/runtime/string.go +++ b/src/runtime/string.go @@ -229,8 +229,13 @@ func stringStructOf(sp *string) *stringStruct { return (*stringStruct)(unsafe.Pointer(sp)) } -func intstring(buf *[4]byte, v int64) string { - var s string +func intstring(buf *[4]byte, v int64) (s string) { + if v >= 0 && v < runeSelf { + stringStructOf(&s).str = unsafe.Pointer(&staticbytes[v]) + stringStructOf(&s).len = 1 + return + } + var b []byte if buf != nil { b = buf[:] |