reduce allocs and improve the render WriteString

This commit is contained in:
yonbiaoxiao 2020-09-21 23:41:44 +08:00
parent 3100b7cb05
commit 87b65d0dd6

View File

@ -7,6 +7,8 @@ package render
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin/internal/bytesconv"
)
// String contains the given interface object slice and its format.
@ -34,6 +36,6 @@ func WriteString(w http.ResponseWriter, format string, data []interface{}) (err
_, err = fmt.Fprintf(w, format, data...)
return
}
_, err = w.Write([]byte(format))
_, err = w.Write(bytesconv.StringToBytes(format))
return
}