Closed smart--petea closed 10 years ago
For now vatican.findMethod is
Vatican.prototype.findMethod = function( url, method ) {
. ..
var match = _.find(this.paths, function(item) {
...
return nmbrOfPartsPath == nmbrOfParts && (item.method.toLowerCase() === method.toLowerCase()) && regExp.test(path);
});
return match;
}
In handlerParser.parse method is uppercased. It can be optimized by
Function become
Vatican.prototype.findMethod = function( url, method ) {
. ..
method = String(method).toUpperCase();
var match = _.find(this.paths, function(item) {
...
return nmbrOfPartsPath == nmbrOfParts && (item.method === method) && regExp.test(path);
});
return match;
}
In findMethod the variables regExpStr and nmbrOfPartsPath are computed at every cycle. It is expensive, isn't it? Maybe to move these computations in handlerParser.parse method.
There are the method
become
to
to
After the apply of these points the function will be