From 1530337c2347e9f90e9a5e43e2bb8bca9049dd27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=BA=A2=E5=B2=A9?= Date: Tue, 13 Dec 2022 23:12:01 +0800 Subject: [PATCH] Optimize code usage --- common/common.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/common.go b/common/common.go index 6c5cee4..14353f4 100644 --- a/common/common.go +++ b/common/common.go @@ -26,8 +26,10 @@ import ( "unsafe" ) -var ( - IntSize = int32(unsafe.Sizeof(0)) +const ( + IntSize = strconv.IntSize + IntSize32 = 32 + intSize64 = 64 ) func Proc(index int) dllimports.ProcAddr { @@ -539,7 +541,7 @@ func CopyBytePtr(bytePtr uintptr, low, high int) []byte { func IntToBytes(i int) []byte { buf := bytes.NewBuffer([]byte{}) - if IntSize == 4 { + if IntSize == IntSize32 { if err := binary.Write(buf, binary.BigEndian, int32(i)); err == nil { return buf.Bytes() } -- GitLab