Bug 1288150 - Adds fast breakpoint presents check for removeBreakpoints. draft
authorYury Delendik <ydelendik@mozilla.com>
Wed, 20 Jul 2016 13:58:16 -0500
changeset 390166 205bfccd221dcebea584a4093a654f11aea34795
parent 389550 5a91e5b49be3c1ba401b057e90c92d7488e3647d
child 525943 6f63a1de09f7d8fb3f98db8db1e8edee28104d31
push id23611
push userydelendik@mozilla.com
push dateWed, 20 Jul 2016 18:58:07 +0000
bugs1288150
milestone50.0a1
Bug 1288150 - Adds fast breakpoint presents check for removeBreakpoints. 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)) {