Bug 1547115 - Memoize breakableLines to avoid resetting in editor often. r=jlast

Differential Revision: https://phabricator.services.mozilla.com/D29245

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Logan Smyth 2019-04-29 21:05:15 +00:00
Родитель 3ba7bef4b0
Коммит 9d48e224c0
2 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -6,7 +6,7 @@
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";
@ -64,9 +64,7 @@ const mapStateToProps = state => {
if (!selectedSource) {
throw new Error("no selectedSource");
}
const breakableLines = new Set(
getBreakableLines(state, selectedSource.id) || []
);
const breakableLines = getSelectedBreakableLines(state);
return {
selectedSource,

Просмотреть файл

@ -881,4 +881,12 @@ export function getBreakableLines(state: OuterState, sourceId: string) {
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;