add memoization to .path. Closes #17

master
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);
},
/**