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

perf($parse): Inline constants #14293

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ ASTCompiler.prototype = {
case AST.Literal:
expression = this.escape(ast.value);
this.assign(intoId, expression);
recursionFn(expression);
recursionFn(intoId || expression);
break;
case AST.UnaryExpression:
this.recurse(ast.argument, undefined, undefined, function(expr) { right = expr; });
Expand Down Expand Up @@ -1046,7 +1046,7 @@ ASTCompiler.prototype = {
self.if_(self.notNull(right), function() {
self.addEnsureSafeFunction(right);
forEach(ast.arguments, function(expr) {
self.recurse(expr, self.nextId(), undefined, function(argument) {
self.recurse(expr, ast.constant ? undefined : self.nextId(), undefined, function(argument) {
args.push(self.ensureSafeObject(argument));
});
});
Expand Down Expand Up @@ -1087,18 +1087,18 @@ ASTCompiler.prototype = {
case AST.ArrayExpression:
args = [];
forEach(ast.elements, function(expr) {
self.recurse(expr, self.nextId(), undefined, function(argument) {
self.recurse(expr, ast.constant ? undefined : self.nextId(), undefined, function(argument) {
args.push(argument);
});
});
expression = '[' + args.join(',') + ']';
this.assign(intoId, expression);
recursionFn(expression);
recursionFn(intoId || expression);
break;
case AST.ObjectExpression:
args = [];
forEach(ast.properties, function(property) {
self.recurse(property.value, self.nextId(), undefined, function(expr) {
self.recurse(property.value, ast.constant ? undefined : self.nextId(), undefined, function(expr) {
args.push(self.escape(
property.key.type === AST.Identifier ? property.key.name :
('' + property.key.value)) +
Expand All @@ -1107,19 +1107,19 @@ ASTCompiler.prototype = {
});
expression = '{' + args.join(',') + '}';
this.assign(intoId, expression);
recursionFn(expression);
recursionFn(intoId || expression);
break;
case AST.ThisExpression:
this.assign(intoId, 's');
recursionFn('s');
recursionFn(intoId || 's');
break;
case AST.LocalsExpression:
this.assign(intoId, 'l');
recursionFn('l');
recursionFn(intoId || 'l');
break;
case AST.NGValueParameter:
this.assign(intoId, 'v');
recursionFn('v');
recursionFn(intoId || 'v');
break;
}
},
Expand Down