mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime/coverage: use unsafe.Slice, not reflect.SliceHeader
Change-Id: I59c4757df83c12b4c8b85cdd523552c5e5e7bf95 Reviewed-on: https://go-review.googlesource.com/c/go/+/508977 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
eaa8419a72
commit
88a545d844
2 changed files with 3 additions and 22 deletions
|
|
@ -8,7 +8,6 @@ import (
|
|||
"fmt"
|
||||
"internal/coverage"
|
||||
"io"
|
||||
"reflect"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
)
|
||||
|
|
@ -158,13 +157,8 @@ func ClearCounters() error {
|
|||
// inconsistency when reading the counter array from the thread
|
||||
// running ClearCounters.
|
||||
|
||||
var sd []atomic.Uint32
|
||||
|
||||
bufHdr := (*reflect.SliceHeader)(unsafe.Pointer(&sd))
|
||||
for _, c := range cl {
|
||||
bufHdr.Data = uintptr(unsafe.Pointer(c.Counters))
|
||||
bufHdr.Len = int(c.Len)
|
||||
bufHdr.Cap = int(c.Len)
|
||||
sd := unsafe.Slice((*atomic.Uint32)(unsafe.Pointer(c.Counters)), int(c.Len))
|
||||
for i := 0; i < len(sd); i++ {
|
||||
// Skip ahead until the next non-zero value.
|
||||
sdi := sd[i].Load()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue