зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1750505 - [devtools] Remove lodash uniqBy usage. r=ochameau
Differential Revision: https://phabricator.services.mozilla.com/D136165
This commit is contained in:
Родитель
c00196fd3f
Коммит
49d84414bf
|
@ -7,7 +7,6 @@ import {
|
|||
isGeneratedId,
|
||||
originalToGeneratedId,
|
||||
} from "devtools-source-map";
|
||||
import { uniqBy } from "lodash";
|
||||
|
||||
import {
|
||||
getSource,
|
||||
|
@ -44,8 +43,24 @@ function filterBySource(positions, sourceId) {
|
|||
return positions.filter(position => position.location.sourceId == sourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge positions that refer to duplicated positions.
|
||||
* Some sourcemaped positions might refer to the exact same source/line/column triple.
|
||||
*
|
||||
* @param {Array<{location, generatedLocation}>} positions: List of possible breakable positions
|
||||
* @returns {Array<{location, generatedLocation}>} A new, filtered array.
|
||||
*/
|
||||
function filterByUniqLocation(positions) {
|
||||
return uniqBy(positions, ({ location }) => makeBreakpointId(location));
|
||||
const handledBreakpointIds = new Set();
|
||||
return positions.filter(({ location }) => {
|
||||
const breakpointId = makeBreakpointId(location);
|
||||
if (handledBreakpointIds.has(breakpointId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
handledBreakpointIds.add(breakpointId);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
function convertToList(results, source) {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
import { createSelector } from "reselect";
|
||||
import { uniqBy } from "lodash";
|
||||
|
||||
import { getBreakpointsList } from "../reducers/breakpoints";
|
||||
import { getSelectedSource } from "../reducers/sources";
|
||||
|
@ -41,9 +40,16 @@ export const getFirstVisibleBreakpoints = createSelector(
|
|||
return [];
|
||||
}
|
||||
|
||||
return uniqBy(
|
||||
sortSelectedBreakpoints(breakpoints, selectedSource),
|
||||
bp => getSelectedLocation(bp, selectedSource).line
|
||||
);
|
||||
// Filter the array so it only return the first breakpoint when there's multiple
|
||||
// breakpoints on the same line.
|
||||
const handledLines = new Set();
|
||||
return sortSelectedBreakpoints(breakpoints, selectedSource).filter(bp => {
|
||||
const line = getSelectedLocation(bp, selectedSource).line;
|
||||
if (handledLines.has(line)) {
|
||||
return false;
|
||||
}
|
||||
handledLines.add(line);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче