From f0aa251dbb977059cc2d9be451c0d24856e2fafd Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Sat, 1 Jul 2023 21:41:51 +0800 Subject: [PATCH] cmd/internal/goobj: use unsafe.String in toString func --- src/cmd/internal/goobj/objfile.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/cmd/internal/goobj/objfile.go b/src/cmd/internal/goobj/objfile.go index c9d7ca434c4..696814390ee 100644 --- a/src/cmd/internal/goobj/objfile.go +++ b/src/cmd/internal/goobj/objfile.go @@ -662,13 +662,7 @@ func toString(b []byte) string { if len(b) == 0 { return "" } - - var s string - hdr := (*unsafeheader.String)(unsafe.Pointer(&s)) - hdr.Data = unsafe.Pointer(&b[0]) - hdr.Len = len(b) - - return s + return unsafe.String(&b[0], len(b)) } func (r *Reader) StringRef(off uint32) string {