mirror of
https://github.com/gin-gonic/gin.git
synced 2025-05-20 17:06:24 +08:00
Performance improvement
- Reduces number of allocations per context - Improves CPU cache usage
This commit is contained in:
4
gin.go
4
gin.go
@ -60,7 +60,9 @@ func New() *Engine {
|
||||
engine.router = httprouter.New()
|
||||
engine.router.NotFound = engine.handle404
|
||||
engine.cache.New = func() interface{} {
|
||||
return &Context{Engine: engine, Writer: &responseWriter{}}
|
||||
c := &Context{Engine: engine}
|
||||
c.Writer = &c.writermem
|
||||
return c
|
||||
}
|
||||
return engine
|
||||
}
|
||||
|
Reference in New Issue
Block a user