From 700a679d20600f65da6341614646f8345ab558bf Mon Sep 17 00:00:00 2001 From: Nicholas Jackson Date: Sun, 3 Mar 2024 13:28:37 -0800 Subject: [PATCH] fix: remove extra alloc on AcquireCtx --- ctx.go | 8 ++++---- ctx_interface.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ctx.go b/ctx.go index 1c6f0dee811..f35a29c1d76 100644 --- a/ctx.go +++ b/ctx.go @@ -42,9 +42,9 @@ type contextKey int const userContextKey contextKey = 0 // __local_user_context__ type DefaultCtx struct { - app *App // Reference to *App - route *Route // Reference to *Route - req *Request // Reference to *Request + app *App // Reference to *App + route *Route // Reference to *Route + req Request // Reference to *Request // res *Response // Reference to *Response indexRoute int // Index of the current route indexHandler int // Index of the current handler @@ -293,7 +293,7 @@ func (c *DefaultCtx) Download(file string, filename ...string) error { // This allows you to use all fasthttp request methods // https://godoc.org/github.com/valyala/fasthttp#Req func (c *DefaultCtx) Req() *Request { - return c.req + return &c.req } // Response return the *fasthttp.Response object diff --git a/ctx_interface.go b/ctx_interface.go index 575b72fcad8..31e0f73f3af 100644 --- a/ctx_interface.go +++ b/ctx_interface.go @@ -502,7 +502,7 @@ func (c *DefaultCtx) setReq(fctx *fasthttp.RequestCtx) { // Attach *fasthttp.RequestCtx to ctx c.fasthttp = fctx - c.req = &Request{ + c.req = Request{ app: c.app, fasthttp: &c.fasthttp.Request, }