From cfb4a981ffe81e080c26c8ad0163e003036473e9 Mon Sep 17 00:00:00 2001 From: mstmdev Date: Thu, 24 Mar 2022 17:31:00 +0800 Subject: [PATCH] Reduce convert between int32 and string in the AsciiJSON.Render function --- render/json.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/render/json.go b/render/json.go index f1f8a6ae..ea052f62 100644 --- a/render/json.go +++ b/render/json.go @@ -150,11 +150,11 @@ func (r AsciiJSON) Render(w http.ResponseWriter) (err error) { var buffer bytes.Buffer for _, r := range bytesconv.BytesToString(ret) { - cvt := string(r) if r >= 128 { - cvt = fmt.Sprintf("\\u%04x", int64(r)) + buffer.WriteString(fmt.Sprintf("\\u%04x", r)) + } else { + buffer.WriteByte(byte(r)) } - buffer.WriteString(cvt) } _, err = w.Write(buffer.Bytes())