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

Commit 341f8db

Browse files
committed
refactor($parse): remove unnecessary .constant if when collecting inputs
1 parent 8de9794 commit 341f8db

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/ng/parse.js

+5-14
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ function findConstantAndWatchExpressions(ast, $filter, parentIsPure) {
705705
findConstantAndWatchExpressions(ast.property, $filter, astIsPure);
706706
}
707707
ast.constant = ast.object.constant && (!ast.computed || ast.property.constant);
708-
ast.toWatch = [ast];
708+
ast.toWatch = ast.constant ? [] : [ast];
709709
break;
710710
case AST.CallExpression:
711711
isStatelessFilter = ast.filter ? isStateless($filter, ast.callee.name) : false;
@@ -714,9 +714,7 @@ function findConstantAndWatchExpressions(ast, $filter, parentIsPure) {
714714
forEach(ast.arguments, function(expr) {
715715
findConstantAndWatchExpressions(expr, $filter, astIsPure);
716716
allConstants = allConstants && expr.constant;
717-
if (!expr.constant) {
718-
argsToWatch.push.apply(argsToWatch, expr.toWatch);
719-
}
717+
argsToWatch.push.apply(argsToWatch, expr.toWatch);
720718
});
721719
ast.constant = allConstants;
722720
ast.toWatch = isStatelessFilter ? argsToWatch : [ast];
@@ -733,9 +731,7 @@ function findConstantAndWatchExpressions(ast, $filter, parentIsPure) {
733731
forEach(ast.elements, function(expr) {
734732
findConstantAndWatchExpressions(expr, $filter, astIsPure);
735733
allConstants = allConstants && expr.constant;
736-
if (!expr.constant) {
737-
argsToWatch.push.apply(argsToWatch, expr.toWatch);
738-
}
734+
argsToWatch.push.apply(argsToWatch, expr.toWatch);
739735
});
740736
ast.constant = allConstants;
741737
ast.toWatch = argsToWatch;
@@ -746,17 +742,12 @@ function findConstantAndWatchExpressions(ast, $filter, parentIsPure) {
746742
forEach(ast.properties, function(property) {
747743
findConstantAndWatchExpressions(property.value, $filter, astIsPure);
748744
allConstants = allConstants && property.value.constant;
749-
if (!property.value.constant) {
750-
argsToWatch.push.apply(argsToWatch, property.value.toWatch);
751-
}
745+
argsToWatch.push.apply(argsToWatch, property.value.toWatch);
752746
if (property.computed) {
753747
findConstantAndWatchExpressions(property.key, $filter, astIsPure);
754748
allConstants = allConstants && property.key.constant;
755-
if (!property.key.constant) {
756-
argsToWatch.push.apply(argsToWatch, property.key.toWatch);
757-
}
749+
argsToWatch.push.apply(argsToWatch, property.key.toWatch);
758750
}
759-
760751
});
761752
ast.constant = allConstants;
762753
ast.toWatch = argsToWatch;

0 commit comments

Comments
 (0)