perf($parse): speed up fn invocation for no args case

This commit is contained in:
Igor Minar
2014-08-01 16:10:09 -07:00
parent cc16340e88
commit a17578ad3d

View File

@@ -723,16 +723,18 @@ Parser.prototype = {
this.consume(')');
var expressionText = this.text;
var args = []; // we can safely reuse the array
// we can safely reuse the array across invocations
var args = argsFn.length ? [] : null;
return function(scope, locals) {
var context = contextGetter ? contextGetter(scope, locals) : scope;
var fn = fnGetter(scope, locals, context) || noop;
var i = argsFn.length;
while (i--) {
args[i] = argsFn[i](scope, locals);
if (args) {
var i = argsFn.length;
while (i--) {
args[i] = argsFn[i](scope, locals);
}
}
ensureSafeObject(context, expressionText);