Removes sync.Pool

This commit is contained in:
Manu Mtz-Almeida 2014-08-18 20:43:34 +02:00
parent d85245b5aa
commit a5ae88722b
3 changed files with 3 additions and 10 deletions

View File

@ -1,5 +1,6 @@
language: go
go:
- 1.2
- 1.3
- tip

View File

@ -70,8 +70,9 @@ type Context struct {
/************************************/
func (engine *Engine) createContext(w http.ResponseWriter, req *http.Request, params httprouter.Params, handlers []HandlerFunc) *Context {
c := engine.cache.Get().(*Context)
c := &Context{Engine: engine}
c.writermem.reset(w)
c.Writer = &c.writermem
c.Request = req
c.Params = params
c.handlers = handlers

9
gin.go
View File

@ -7,7 +7,6 @@ import (
"math"
"net/http"
"path"
"sync"
)
const (
@ -36,7 +35,6 @@ type (
Engine struct {
*RouterGroup
HTMLRender render.Render
cache sync.Pool
finalNoRoute []HandlerFunc
noRoute []HandlerFunc
router *httprouter.Router
@ -55,7 +53,6 @@ func (engine *Engine) handle404(w http.ResponseWriter, req *http.Request) {
c.Writer.WriteHeaderNow()
}
}
engine.cache.Put(c)
}
// Returns a new blank Engine instance without any middleware attached.
@ -65,11 +62,6 @@ func New() *Engine {
engine.RouterGroup = &RouterGroup{nil, "/", nil, engine}
engine.router = httprouter.New()
engine.router.NotFound = engine.handle404
engine.cache.New = func() interface{} {
c := &Context{Engine: engine}
c.Writer = &c.writermem
return c
}
return engine
}
@ -172,7 +164,6 @@ func (group *RouterGroup) Handle(method, p string, handlers []HandlerFunc) {
c := group.engine.createContext(w, req, params, handlers)
c.Next()
c.Writer.WriteHeaderNow()
group.engine.cache.Put(c)
})
}