Bug 1189664 - Take a fast shortcut when searching for BreakpointActors and the map is empty; r=jsantell
authorNick Fitzgerald <fitzgen@gmail.com>
Fri, 31 Jul 2015 17:22:28 -0700
changeset 287385 de94f408a90191eaf57a1e3266f0f705a9b7be45
parent 287384 d4446e517b3aef8b3766882ceca912fa0e1b7c33
child 287386 70041285743416985d75534de430263d58644ade
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsantell
bugs1189664
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1189664 - Take a fast shortcut when searching for BreakpointActors and the map is empty; r=jsantell
toolkit/devtools/server/actors/script.js
--- a/toolkit/devtools/server/actors/script.js
+++ b/toolkit/devtools/server/actors/script.js
@@ -55,16 +55,23 @@ BreakpointActorMap.prototype = {
   /**
    * Generate all BreakpointActors that match the given location in
    * this BreakpointActorMap.
    *
    * @param OriginalLocation location
    *        The location for which matching BreakpointActors should be generated.
    */
   findActors: function* (location = new OriginalLocation()) {
+    // Fast shortcut for when we know we won't find any actors. Surprisingly
+    // enough, this speeds up refreshing when there are no breakpoints set by
+    // about 2x!
+    if (this.size === 0) {
+      return;
+    }
+
     function* findKeys(object, key) {
       if (key !== undefined) {
         if (key in object) {
           yield key;
         }
       }
       else {
         for (let key of Object.keys(object)) {