perf(server): pass ctx.Path() directly to Match, eliminate string alloc
Removes the string(ctx.Path()) conversion that caused one heap allocation per request in the routing hot path.
This commit is contained in:
parent
aef0d8357b
commit
1eeab88c98
@ -526,8 +526,7 @@ func (s *Server) startSingleMode() error {
|
|||||||
// 创建主请求处理器,使用 LocationEngine 匹配路由
|
// 创建主请求处理器,使用 LocationEngine 匹配路由
|
||||||
locationEngine := s.locationEngine
|
locationEngine := s.locationEngine
|
||||||
baseHandler := func(ctx *fasthttp.RequestCtx) {
|
baseHandler := func(ctx *fasthttp.RequestCtx) {
|
||||||
path := string(ctx.Path())
|
result := locationEngine.Match(ctx.Path())
|
||||||
result := locationEngine.Match(path)
|
|
||||||
if result != nil && result.Handler != nil {
|
if result != nil && result.Handler != nil {
|
||||||
result.Handler(ctx)
|
result.Handler(ctx)
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user