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

Commit

Permalink
perf($compile): wrap try/catch of collect comment directives into a f…
Browse files Browse the repository at this point in the history
…unction to avoid V8 deopt
  • Loading branch information
drpicox committed Jun 30, 2016
1 parent f7405e3 commit d3fd76e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/ng/compile.js
Expand Up @@ -2052,6 +2052,16 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
addTextInterpolateDirective(directives, node.nodeValue);
break;
case NODE_TYPE_COMMENT: /* Comment */
collectCommentDirectives();
break;
}

directives.sort(byPriority);
return directives;

function collectCommentDirectives() {
// function created because of performance, try/catch disables
// the optimization of the whole function #14848
try {
match = COMMENT_DIRECTIVE_REGEXP.exec(node.nodeValue);
if (match) {
Expand All @@ -2065,11 +2075,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
// comment's node value.
// Just ignore it and continue. (Can't seem to reproduce in test case.)
}
break;
}

directives.sort(byPriority);
return directives;
}

/**
Expand Down

0 comments on commit d3fd76e

Please sign in to comment.