Bug 865328: debug protocol client: capture a 'self' variable, instead of doing lots of 'bind' calls. r=msucan
authorJim Blandy <jimb@mozilla.com>
Tue, 30 Apr 2013 15:18:04 -0700
changeset 141365 6f094b0083d34e8d650921fe01bff4ace607534f
parent 141356 0c6b9bedfa654a57d7c41e83f9c323e8370274d3
child 141366 de9d4e1505a9322a4ec739fa58dc62f35bdc114f
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmsucan
bugs865328
milestone23.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 865328: debug protocol client: capture a 'self' variable, instead of doing lots of 'bind' calls. r=msucan This lets us use ordinary function declarations, which can appear in the order the code will run, for legibility.
toolkit/devtools/debugger/dbg-client.jsm
--- a/toolkit/devtools/debugger/dbg-client.jsm
+++ b/toolkit/devtools/debugger/dbg-client.jsm
@@ -343,56 +343,58 @@ DebuggerClient.prototype = {
     this._eventsEnabled = false;
 
     if (aOnClosed) {
       this.addOneTimeListener('closed', function(aEvent) {
         aOnClosed();
       });
     }
 
-    let closeTransport = function _closeTransport() {
-      this._transport.close();
-      this._transport = null;
-    }.bind(this);
-
-    let detachTab = function _detachTab() {
-      if (this.activeTab) {
-        this.activeTab.detach(closeTransport);
-      } else {
-        closeTransport();
-      }
-    }.bind(this);
-
-    let detachThread = function _detachThread() {
-      if (this.activeThread) {
-        this.activeThread.detach(detachTab);
-      } else {
-        detachTab();
-      }
-    }.bind(this);
+    let self = this;
 
     let consolesClosed = 0;
     let consolesToClose = 0;
 
-    let onConsoleClose = function _onConsoleClose() {
-      consolesClosed++;
-      if (consolesClosed >= consolesToClose) {
-        this._consoleClients = {};
-        detachThread();
-      }
-    }.bind(this);
-
     for each (let client in this._consoleClients) {
       consolesToClose++;
       client.close(onConsoleClose);
     }
 
     if (!consolesToClose) {
       detachThread();
     }
+
+    function onConsoleClose() {
+      consolesClosed++;
+      if (consolesClosed >= consolesToClose) {
+        self._consoleClients = {};
+        detachThread();
+      }
+    }
+
+    function detachThread() {
+      if (self.activeThread) {
+        self.activeThread.detach(detachTab);
+      } else {
+        detachTab();
+      }
+    }
+
+    function detachTab() {
+      if (self.activeTab) {
+        self.activeTab.detach(closeTransport);
+      } else {
+        closeTransport();
+      }
+    }
+
+    function closeTransport() {
+      self._transport.close();
+      self._transport = null;
+    }
   },
 
   /**
    * List the open tabs.
    *
    * @param function aOnResponse
    *        Called with the response packet.
    */