Improved performance

This commit is contained in:
2024-03-14 15:11:00 +01:00
parent 1e4161de0c
commit d89859010b
4 changed files with 27 additions and 22 deletions

View File

@ -57,7 +57,10 @@ func New() Server {
}
s.pool.New = func() any {
return &ctx{server: s}
return &ctx{
server: s,
params: make([]param, 0, 8),
}
}
return s
@ -94,7 +97,7 @@ func (s *server) ServeHTTP(response http.ResponseWriter, request *http.Request)
s.errorHandler(ctx, err)
}
ctx.paramCount = 0
ctx.params = ctx.params[:0]
ctx.handlerCount = 0
s.pool.Put(ctx)
}