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

Commit d3fd76e

Browse files
committed
perf($compile): wrap try/catch of collect comment directives into a function to avoid V8 deopt
1 parent f7405e3 commit d3fd76e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/ng/compile.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,16 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
20522052
addTextInterpolateDirective(directives, node.nodeValue);
20532053
break;
20542054
case NODE_TYPE_COMMENT: /* Comment */
2055+
collectCommentDirectives();
2056+
break;
2057+
}
2058+
2059+
directives.sort(byPriority);
2060+
return directives;
2061+
2062+
function collectCommentDirectives() {
2063+
// function created because of performance, try/catch disables
2064+
// the optimization of the whole function #14848
20552065
try {
20562066
match = COMMENT_DIRECTIVE_REGEXP.exec(node.nodeValue);
20572067
if (match) {
@@ -2065,11 +2075,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
20652075
// comment's node value.
20662076
// Just ignore it and continue. (Can't seem to reproduce in test case.)
20672077
}
2068-
break;
20692078
}
2070-
2071-
directives.sort(byPriority);
2072-
return directives;
20732079
}
20742080

20752081
/**

0 commit comments

Comments
 (0)