Performance improvement

- Reduces number of allocations per context
- Improves CPU cache usage
This commit is contained in:
Manu Mtz-Almeida
2014-07-18 00:10:28 +02:00
parent 184a02ee2d
commit 48f4914165
3 changed files with 14 additions and 11 deletions

4
gin.go
View File

@ -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
}