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--) {
|
while (n--) {
|
||||||
app.use(function(next){
|
app.use(function(next){
|
||||||
return function *(){
|
return function *(){
|
||||||
|
var p = this.path;
|
||||||
yield next;
|
yield next;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue