diff options
author | Michael Hudson-Doyle <michael.hudson@canonical.com> | 2015-04-11 10:01:54 +1200 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2015-04-15 16:59:49 +0000 |
commit | ab4df700b841fcd9a5d249b77c547bad9574d948 (patch) | |
tree | d6edc85b7486f5cb33bdc4f9bbff2d77a26a97d5 /src/runtime/slice.go | |
parent | f7be77e5b61706b6264367c43b78a9a4a93f8f3a (diff) | |
download | go-ab4df700b841fcd9a5d249b77c547bad9574d948.tar.gz go-ab4df700b841fcd9a5d249b77c547bad9574d948.zip |
runtime: merge slice and sliceStruct
By removing type slice, renaming type sliceStruct to type slice and
whacking until it compiles.
Has a pleasing net reduction of conversions.
Fixes #10188
Change-Id: I77202b8df637185b632fd7875a1fdd8d52c7a83c
Reviewed-on: https://go-review.googlesource.com/8770
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/slice.go')
-rw-r--r-- | src/runtime/slice.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/runtime/slice.go b/src/runtime/slice.go index ae46d9c1ac..cf2510aeb2 100644 --- a/src/runtime/slice.go +++ b/src/runtime/slice.go @@ -8,14 +8,14 @@ import ( "unsafe" ) -type sliceStruct struct { +type slice struct { array unsafe.Pointer len int cap int } // TODO: take uintptrs instead of int64s? -func makeslice(t *slicetype, len64 int64, cap64 int64) sliceStruct { +func makeslice(t *slicetype, len64, cap64 int64) slice { // NOTE: The len > MaxMem/elemsize check here is not strictly necessary, // but it produces a 'len out of range' error instead of a 'cap out of range' error // when someone does make([]T, bignumber). 'cap out of range' is true too, @@ -30,10 +30,10 @@ func makeslice(t *slicetype, len64 int64, cap64 int64) sliceStruct { panic(errorString("makeslice: cap out of range")) } p := newarray(t.elem, uintptr(cap)) - return sliceStruct{p, len, cap} + return slice{p, len, cap} } -func growslice(t *slicetype, old sliceStruct, n int) sliceStruct { +func growslice(t *slicetype, old slice, n int) slice { if n < 1 { panic(errorString("growslice: invalid n")) } @@ -52,7 +52,7 @@ func growslice(t *slicetype, old sliceStruct, n int) sliceStruct { if et.size == 0 { // append should not create a slice with nil pointer but non-zero len. // We assume that append doesn't need to preserve old.array in this case. - return sliceStruct{unsafe.Pointer(&zerobase), old.len, cap} + return slice{unsafe.Pointer(&zerobase), old.len, cap} } newcap := old.cap @@ -91,10 +91,10 @@ func growslice(t *slicetype, old sliceStruct, n int) sliceStruct { } } - return sliceStruct{p, old.len, newcap} + return slice{p, old.len, newcap} } -func slicecopy(to sliceStruct, fm sliceStruct, width uintptr) int { +func slicecopy(to, fm slice, width uintptr) int { if fm.len == 0 || to.len == 0 { return 0 } |