Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit a17578a

Browse files
committed
perf($parse): speed up fn invocation for no args case
1 parent cc16340 commit a17578a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/ng/parse.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -723,16 +723,18 @@ Parser.prototype = {
723723
this.consume(')');
724724

725725
var expressionText = this.text;
726-
var args = []; // we can safely reuse the array
726+
// we can safely reuse the array across invocations
727+
var args = argsFn.length ? [] : null;
727728

728729
return function(scope, locals) {
729730
var context = contextGetter ? contextGetter(scope, locals) : scope;
730731
var fn = fnGetter(scope, locals, context) || noop;
731732

732-
733-
var i = argsFn.length;
734-
while (i--) {
735-
args[i] = argsFn[i](scope, locals);
733+
if (args) {
734+
var i = argsFn.length;
735+
while (i--) {
736+
args[i] = argsFn[i](scope, locals);
737+
}
736738
}
737739

738740
ensureSafeObject(context, expressionText);

0 commit comments

Comments
 (0)