add memoization to .path. Closes #17
This commit is contained in:
parent
832a1dcc1e
commit
933ecd8747
2 changed files with 3 additions and 2 deletions
|
@ -11,6 +11,7 @@ console.log(' %s middleware', n);
|
|||
while (n--) {
|
||||
app.use(function(next){
|
||||
return function *(){
|
||||
var p = this.path;
|
||||
yield next;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue