reduce allocs and improve the render WriteString
(#2508)
Co-authored-by: yonbiaoxiao <yonbiaoxiao@tencent.com> Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com> Co-authored-by: thinkerou <thinkerou@gmail.com>
This commit is contained in:
parent
d541085b59
commit
c83a1cca0a
@ -7,6 +7,8 @@ package render
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin/internal/bytesconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// String contains the given interface object slice and its format.
|
// 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...)
|
_, err = fmt.Fprintf(w, format, data...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = w.Write([]byte(format))
|
_, err = w.Write(bytesconv.StringToBytes(format))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user