From a5ae88722b552adf00b87c7ae5f2fb84d56ebe6f Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Mon, 18 Aug 2014 20:43:34 +0200 Subject: [PATCH] Removes sync.Pool --- .travis.yml | 1 + context.go | 3 ++- gin.go | 9 --------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 98b43464..1b1a9d0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: go go: + - 1.2 - 1.3 - tip diff --git a/context.go b/context.go index 8fed41de..42943f2e 100644 --- a/context.go +++ b/context.go @@ -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 diff --git a/gin.go b/gin.go index 99c5cbce..e30e38e9 100644 --- a/gin.go +++ b/gin.go @@ -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) }) }