зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1737978 - [devtools] Remove lodash memoize usage. r=ochameau.
Differential Revision: https://phabricator.services.mozilla.com/D136172
This commit is contained in:
Родитель
6748189c7e
Коммит
e66b0059a3
|
@ -7,7 +7,6 @@ import { connect } from "../../../utils/connect";
|
|||
import { createSelector } from "reselect";
|
||||
import classnames from "classnames";
|
||||
import actions from "../../../actions";
|
||||
import { memoize } from "lodash";
|
||||
|
||||
import showContextMenu from "./BreakpointsContextMenu";
|
||||
import { CloseButton } from "../../shared/Button";
|
||||
|
@ -102,14 +101,11 @@ class Breakpoint extends PureComponent {
|
|||
return logValue || condition || getSelectedText(breakpoint, selectedSource);
|
||||
}
|
||||
|
||||
highlightText = memoize(
|
||||
(text = "", editor) => {
|
||||
highlightText(text = "", editor) {
|
||||
const node = document.createElement("div");
|
||||
editor.CodeMirror.runMode(text, "application/javascript", node);
|
||||
return { __html: node.innerHTML };
|
||||
},
|
||||
text => text
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { breakpoint, editor } = this.props;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* 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/>. */
|
||||
|
||||
import { memoize } from "lodash";
|
||||
import { URL as URLParser } from "whatwg-url";
|
||||
|
||||
const defaultUrl = {
|
||||
|
@ -22,7 +21,12 @@ const defaultUrl = {
|
|||
username: "",
|
||||
};
|
||||
|
||||
export const stripQuery = memoize(function stripQueryAndHash(url) {
|
||||
const stripQueryCache = new Map();
|
||||
export function stripQuery(url) {
|
||||
if (stripQueryCache.has(url)) {
|
||||
return stripQueryCache.get(url);
|
||||
}
|
||||
|
||||
let queryStart = url.indexOf("?");
|
||||
|
||||
let before = url;
|
||||
|
@ -40,10 +44,17 @@ export const stripQuery = memoize(function stripQueryAndHash(url) {
|
|||
before = url.slice(0, queryStart);
|
||||
}
|
||||
|
||||
return before + after;
|
||||
});
|
||||
const result = before + after;
|
||||
stripQueryCache.set(url, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
const parseCache = new Map();
|
||||
export function parse(url) {
|
||||
if (parseCache.has(url)) {
|
||||
return parseCache.get(url);
|
||||
}
|
||||
|
||||
export const parse = memoize(function parse(url) {
|
||||
let urlObj;
|
||||
try {
|
||||
urlObj = new URLParser(url);
|
||||
|
@ -80,8 +91,10 @@ export const parse = memoize(function parse(url) {
|
|||
}
|
||||
urlObj.path = urlObj.pathname + urlObj.search;
|
||||
|
||||
// Cache the result
|
||||
parseCache.set(url, urlObj);
|
||||
return urlObj;
|
||||
});
|
||||
}
|
||||
|
||||
export function sameOrigin(firstUrl, secondUrl) {
|
||||
return parse(firstUrl).origin == parse(secondUrl).origin;
|
||||
|
|
Загрузка…
Ссылка в новой задаче