Improved performance

This commit is contained in:
Eduard Urbach 2024-03-14 00:06:20 +01:00
parent 322f6acbca
commit 5653479928
Signed by: eduard
GPG key ID: 49226B848C78F6C8
3 changed files with 10 additions and 16 deletions

View file

@ -40,17 +40,6 @@ type ctx struct {
handlerCount int
}
// newContext returns a new context from the pool.
func newContext(req *http.Request, res http.ResponseWriter, server *Server) *ctx {
ctx := contextPool.Get().(*ctx)
ctx.request = req
ctx.response = res
ctx.server = server
ctx.paramCount = 0
ctx.handlerCount = 0
return ctx
}
// Bytes responds with a raw byte slice.
func (ctx *ctx) Bytes(body []byte) error {
_, err := ctx.response.Write(body)