Bug 1547115 - Memoize breakableLines to avoid resetting in editor often. r=jlast
authorLogan Smyth <loganfsmyth@gmail.com>
Mon, 29 Apr 2019 21:05:15 +0000
changeset 471822 5293fd5ae92fe1a2759ea318bdca574fbc7892fd
parent 471821 fa6be110a460610cfa89efcfeda08d9d57e4915b
child 471823 17c0c0c8627c4a18f3824a3e62d6e58dbb300ad7
push id35935
push usershindli@mozilla.com
push dateTue, 30 Apr 2019 03:46:04 +0000
treeherdermozilla-central@f3c2a7206699 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1547115
milestone68.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 1547115 - Memoize breakableLines to avoid resetting in editor often. r=jlast Differential Revision: https://phabricator.services.mozilla.com/D29245
devtools/client/debugger/src/components/Editor/EmptyLines.js
devtools/client/debugger/src/reducers/sources.js
--- a/devtools/client/debugger/src/components/Editor/EmptyLines.js
+++ b/devtools/client/debugger/src/components/Editor/EmptyLines.js
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
 
 // @flow
 
 import { connect } from "../../utils/connect";
 import { Component } from "react";
-import { getSelectedSource, getBreakableLines } from "../../selectors";
+import { getSelectedSource, getSelectedBreakableLines } from "../../selectors";
 import type { Source } from "../../types";
 import { fromEditorLine } from "../../utils/editor";
 
 type Props = {
   selectedSource: Source,
   editor: Object,
   breakableLines: Set<number>
 };
@@ -59,19 +59,17 @@ class EmptyLines extends Component<Props
   }
 }
 
 const mapStateToProps = state => {
   const selectedSource = getSelectedSource(state);
   if (!selectedSource) {
     throw new Error("no selectedSource");
   }
-  const breakableLines = new Set(
-    getBreakableLines(state, selectedSource.id) || []
-  );
+  const breakableLines = getSelectedBreakableLines(state);
 
   return {
     selectedSource,
     breakableLines
   };
 };
 
 export default connect(mapStateToProps)(EmptyLines);
--- a/devtools/client/debugger/src/reducers/sources.js
+++ b/devtools/client/debugger/src/reducers/sources.js
@@ -876,9 +876,17 @@ export function getBreakpointPositionsFo
 export function getBreakableLines(state: OuterState, sourceId: string) {
   if (!sourceId) {
     return null;
   }
 
   return state.sources.breakableLines[sourceId];
 }
 
+export const getSelectedBreakableLines: Selector<Set<number>> = createSelector(
+  state => {
+    const sourceId = getSelectedSourceId(state);
+    return sourceId && state.sources.breakableLines[sourceId];
+  },
+  breakableLines => new Set(breakableLines || [])
+);
+
 export default update;