mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
f7be77e5b6
commit
ab4df700b8
10 changed files with 36 additions and 46 deletions
|
|
@ -148,12 +148,12 @@ func recordspan(vh unsafe.Pointer, p unsafe.Pointer) {
|
|||
}
|
||||
var new []*mspan
|
||||
sp := (*slice)(unsafe.Pointer(&new))
|
||||
sp.array = (*byte)(sysAlloc(uintptr(n)*ptrSize, &memstats.other_sys))
|
||||
sp.array = sysAlloc(uintptr(n)*ptrSize, &memstats.other_sys)
|
||||
if sp.array == nil {
|
||||
throw("runtime: cannot allocate memory")
|
||||
}
|
||||
sp.len = uint(len(h_allspans))
|
||||
sp.cap = uint(n)
|
||||
sp.len = len(h_allspans)
|
||||
sp.cap = n
|
||||
if len(h_allspans) > 0 {
|
||||
copy(new, h_allspans)
|
||||
// Don't free the old array if it's referenced by sweep.
|
||||
|
|
@ -256,9 +256,9 @@ func mHeap_Init(h *mheap, spans_size uintptr) {
|
|||
}
|
||||
|
||||
sp := (*slice)(unsafe.Pointer(&h_spans))
|
||||
sp.array = (*byte)(unsafe.Pointer(h.spans))
|
||||
sp.len = uint(spans_size / ptrSize)
|
||||
sp.cap = uint(spans_size / ptrSize)
|
||||
sp.array = unsafe.Pointer(h.spans)
|
||||
sp.len = int(spans_size / ptrSize)
|
||||
sp.cap = int(spans_size / ptrSize)
|
||||
}
|
||||
|
||||
func mHeap_MapSpans(h *mheap) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue