Bug 1288150 - Adds fast breakpoint presents check for removeBreakpoints. r?jlongster draft
authorYury Delendik <ydelendik@mozilla.com>
Thu, 21 Jul 2016 08:52:00 -0500
changeset 390605 0ea3e7d06c3695a68ca2553194e2bb916cc89fd6
parent 389550 5a91e5b49be3c1ba401b057e90c92d7488e3647d
child 526030 44667e17ec143e0a8f3679bbfe49437146689dbd
push id23707
push userydelendik@mozilla.com
push dateThu, 21 Jul 2016 13:52:07 +0000
reviewersjlongster
bugs1288150
milestone50.0a1
Bug 1288150 - Adds fast breakpoint presents check for removeBreakpoints. r?jlongster MozReview-Commit-ID: KKDUw6st4Bs
devtools/client/sourceeditor/debugger.js
--- a/devtools/client/sourceeditor/debugger.js
+++ b/devtools/client/sourceeditor/debugger.js
@@ -185,17 +185,25 @@ function addBreakpoint(ctx, line, cond) 
 function removeBreakpoints(ctx) {
   let { ed, cm } = ctx;
 
   let meta = dbginfo.get(ed);
   if (meta.breakpoints != null) {
     meta.breakpoints = {};
   }
 
-  cm.doc.iter((line) => { removeBreakpoint(ctx, line); });
+  cm.doc.iter((line) => {
+    // The hasBreakpoint is a slow operation: checks the line type, whether cm
+    // is initialized and creates several new objects. Inlining the line's
+    // wrapClass property check directly.
+    if (line.wrapClass == null || !line.wrapClass.includes("breakpoint")) {
+      return;
+    }
+    removeBreakpoint(ctx, line);
+  });
 }
 
 /**
  * Removes a visual breakpoint from a specified line and
  * makes Editor emit a breakpointRemoved event.
  */
 function removeBreakpoint(ctx, line) {
   if (!hasBreakpoint(ctx, line)) {