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

Commit fecfc5b

Browse files
committed
perf($parse): speed up fn invocation by optimizing arg collection
8-15% improvement for depending on the number of args
1 parent 6f5fc55 commit fecfc5b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/ng/parse.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -723,14 +723,17 @@ Parser.prototype = {
723723
this.consume(')');
724724

725725
var parser = this;
726+
var args = []; // we can safely reuse the array
726727

727728
return function(scope, locals) {
728-
var args = [];
729729
var context = contextGetter ? contextGetter(scope, locals) : scope;
730730

731-
for (var i = 0; i < argsFn.length; i++) {
732-
args.push(argsFn[i](scope, locals));
731+
732+
var i = argsFn.length;
733+
while (i--) {
734+
args[i] = argsFn[i](scope, locals);
733735
}
736+
734737
var fnPtr = fn(scope, locals, context) || noop;
735738

736739
ensureSafeObject(context, parser.text);

0 commit comments

Comments
 (0)