add memoization to .path. Closes #17

This commit is contained in:
TJ Holowaychuk 2013-08-22 17:58:51 -07:00
parent 832a1dcc1e
commit 933ecd8747
2 changed files with 3 additions and 2 deletions

View file

@ -11,6 +11,7 @@ console.log(' %s middleware', n);
while (n--) { while (n--) {
app.use(function(next){ app.use(function(next){
return function *(){ return function *(){
var p = this.path;
yield next; yield next;
} }
}); });

View file

@ -142,8 +142,8 @@ module.exports = {
*/ */
get path() { get path() {
// TODO: memoize var c = this._pc = this._pc || {};
return parse(this.url).pathname; return c[this.url] || (c[this.url] = parse(this.url).pathname);
}, },
/** /**