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--) {
app.use(function(next){
return function *(){
var p = this.path;
yield next;
}
});

View file

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