mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-23 10:02:10 +08:00
use buffer instead of concatenate
This commit is contained in:
parent
64d474b2a2
commit
fe1abc5293
@ -126,7 +126,7 @@ func (r AsciiJSON) Render(w http.ResponseWriter) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
result := ""
|
var buffer bytes.Buffer
|
||||||
for _, r := range string(ret) {
|
for _, r := range string(ret) {
|
||||||
cvt := ""
|
cvt := ""
|
||||||
if r < 128 {
|
if r < 128 {
|
||||||
@ -134,10 +134,10 @@ func (r AsciiJSON) Render(w http.ResponseWriter) (err error) {
|
|||||||
} else {
|
} else {
|
||||||
cvt = fmt.Sprintf("\\u%04x", int64(r))
|
cvt = fmt.Sprintf("\\u%04x", int64(r))
|
||||||
}
|
}
|
||||||
result = result + cvt
|
buffer.WriteString(cvt)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write([]byte(result))
|
w.Write(buffer.Bytes())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user