diff --git a/benchmarks/middleware.js b/benchmarks/middleware.js index cce3276..300b892 100644 --- a/benchmarks/middleware.js +++ b/benchmarks/middleware.js @@ -11,7 +11,6 @@ console.log(' %s middleware', n); while (n--) { app.use(function(next){ return function *(){ - var p = this.path; yield next; } }); diff --git a/benchmarks/run b/benchmarks/run index d1ad6d4..862acb1 100755 --- a/benchmarks/run +++ b/benchmarks/run @@ -6,7 +6,7 @@ pid=$! sleep 2 -wrk http://localhost:3000/ \ +wrk 'http://localhost:3000/?foo[bar]=baz' \ -r 2000 \ -c 50 \ -t 4 \ diff --git a/lib/context.js b/lib/context.js index cf442bf..4429d1d 100644 --- a/lib/context.js +++ b/lib/context.js @@ -142,7 +142,7 @@ module.exports = { */ get path() { - var c = this._pc = this._pc || {}; + var c = this._pathcache = this._pathcache || {}; return c[this.url] || (c[this.url] = parse(this.url).pathname); }, @@ -169,7 +169,9 @@ module.exports = { get query() { var str = this.querystring; if (!str) return {}; - return qs.parse(str); + + var c = this._querycache = this._querycache || {}; + return c[str] || (c[str] = qs.parse(str)); }, /**