From a09fa356416c033a52666f3becf00524ecff3a03 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sun, 10 Aug 2014 07:08:57 -0700 Subject: [PATCH] perf(Scope): exit $broadcast early if nobody is listening for the given event --- src/ng/rootScope.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index 2b369d44..23fd7bf0 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -1148,8 +1148,11 @@ function $RootScopeProvider(){ event.defaultPrevented = true; }, defaultPrevented: false - }, - listenerArgs = concat([event], arguments, 1), + }; + + if (!target.$$listenerCount[name]) return event; + + var listenerArgs = concat([event], arguments, 1), listeners, i, length; //down while you can, then up and next sibling or up and next sibling until back at root