From d5351e53ec33d72c9d82a7680888fc62a2e2880d Mon Sep 17 00:00:00 2001 From: David Rodenas Pico Date: Thu, 30 Jun 2016 09:52:04 +0200 Subject: [PATCH] perf($compile): wrap try/catch of collect comment directives into a function to avoid V8 deopt --- src/ng/compile.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 68e49f2bcaf1..015886976efe 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -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) { @@ -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; } /**