diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2015-02-27 15:13:05 +0900 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2015-03-04 17:17:17 +0000 |
| commit | 81d4072eb062a6af09e9a36314887a88acd50ebf (patch) | |
| tree | e5453360d621a99a23d99d155563934d5bc118e5 /src/runtime | |
| parent | 3d0397a4f4f4034f4cb330ec7e5b05a359a86196 (diff) | |
| download | go-81d4072eb062a6af09e9a36314887a88acd50ebf.tar.xz | |
cmd/internal/gc, runtime: change growslice to use int instead of int64
Gc already calculates n as an int, so converting to int64 to call
growslice doesn't serve any purpose except to emit slightly larger
code on 32-bit platforms. Passing n as an int shrinks godoc's text
segment by 8kB (9472633 => 9464133) when building for ARM.
Change-Id: Ief9492c21d01afcb624d3f2a484df741450b788d
Reviewed-on: https://go-review.googlesource.com/6231
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/slice.go | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/runtime/slice.go b/src/runtime/slice.go index 62d6b7ce87..7a2eb624b7 100644 --- a/src/runtime/slice.go +++ b/src/runtime/slice.go @@ -33,16 +33,13 @@ func makeslice(t *slicetype, len64 int64, cap64 int64) sliceStruct { return sliceStruct{p, len, cap} } -// TODO: take uintptr instead of int64? -func growslice(t *slicetype, old sliceStruct, n int64) sliceStruct { +func growslice(t *slicetype, old sliceStruct, n int) sliceStruct { if n < 1 { panic(errorString("growslice: invalid n")) } - cap64 := int64(old.cap) + n - cap := int(cap64) - - if int64(cap) != cap64 || cap < old.cap || t.elem.size > 0 && uintptr(cap) > _MaxMem/uintptr(t.elem.size) { + cap := old.cap + n + if cap < old.cap || t.elem.size > 0 && uintptr(cap) > _MaxMem/uintptr(t.elem.size) { panic(errorString("growslice: cap out of range")) } |
