From 4fe4601d37179facbf7e79627ef9d6a236364505 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Sat, 3 Sep 2022 14:29:35 +0800 Subject: runtime: simplify code using unsafe.{Slice,String} Updates #54854 Change-Id: Ie18665e93e477b6f220acf4c6c070b2af4343064 Reviewed-on: https://go-review.googlesource.com/c/go/+/428157 Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Reviewed-by: Bryan Mills Auto-Submit: Ian Lance Taylor --- src/runtime/debuglog.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/runtime/debuglog.go') diff --git a/src/runtime/debuglog.go b/src/runtime/debuglog.go index 028d77ad41..83d5a3e9e6 100644 --- a/src/runtime/debuglog.go +++ b/src/runtime/debuglog.go @@ -657,11 +657,7 @@ func (r *debugLogReader) printVal() bool { case debugLogConstString: len, ptr := int(r.uvarint()), uintptr(r.uvarint()) ptr += firstmoduledata.etext - str := stringStruct{ - str: unsafe.Pointer(ptr), - len: len, - } - s := *(*string)(unsafe.Pointer(&str)) + s := unsafe.String((*byte)(unsafe.Pointer(ptr)), len) print(s) case debugLogStringOverflow: -- cgit v1.3-5-g9baa