Bug 1541631 - Part 5: Remove exitEarly option from memoizableAction since it isn't needed. r=jlast
☠☠ backed out by db9aaec44445 ☠ ☠
authorLogan Smyth <loganfsmyth@gmail.com>
Thu, 15 Aug 2019 16:28:25 +0000
changeset 488269 9f928da98d32a29631d35fd6787c6c36bb038bef
parent 488268 53b83b8e37e0986e048db3c40ddbf6d59a515660
child 488270 6db731f26958d5f6ab2f6b3166a3d77e4cfeacaa
push id36440
push userncsoregi@mozilla.com
push dateFri, 16 Aug 2019 03:57:48 +0000
treeherdermozilla-central@a58b7dc85887 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1541631
milestone70.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 1541631 - Part 5: Remove exitEarly option from memoizableAction since it isn't needed. r=jlast Differential Revision: https://phabricator.services.mozilla.com/D42030
devtools/client/debugger/src/actions/sources/loadSourceText.js
devtools/client/debugger/src/actions/sources/symbols.js
devtools/client/debugger/src/reducers/sources.js
devtools/client/debugger/src/utils/memoizableAction.js
--- a/devtools/client/debugger/src/actions/sources/loadSourceText.js
+++ b/devtools/client/debugger/src/actions/sources/loadSourceText.js
@@ -134,23 +134,26 @@ export function loadSourceById(cx: Conte
     return dispatch(loadSourceText({ cx, source }));
   };
 }
 
 export const loadSourceText: MemoizedAction<
   { cx: Context, source: Source },
   ?Source
 > = memoizeableAction("loadSourceText", {
-  exitEarly: ({ source }) => !source,
   hasValue: ({ source }, { getState }) => {
-    return !!(
-      getSource(getState(), source.id) &&
-      getSourceWithContent(getState(), source.id).content
+    return (
+      !source ||
+      !!(
+        getSource(getState(), source.id) &&
+        getSourceWithContent(getState(), source.id).content
+      )
     );
   },
-  getValue: ({ source }, { getState }) => getSource(getState(), source.id),
+  getValue: ({ source }, { getState }) =>
+    source ? getSource(getState(), source.id) : null,
   createKey: ({ source }, { getState }) => {
     const epoch = getSourcesEpoch(getState());
     return `${epoch}:${source.id}`;
   },
   action: ({ cx, source }, thunkArgs) =>
     loadSourceTextPromise(cx, source, thunkArgs),
 });
--- a/devtools/client/debugger/src/actions/sources/symbols.js
+++ b/devtools/client/debugger/src/actions/sources/symbols.js
@@ -38,15 +38,16 @@ async function doSetSymbols(cx, source, 
   return symbols;
 }
 
 type Args = { cx: Context, source: Source };
 
 export const setSymbols: MemoizedAction<Args, ?Symbols> = memoizeableAction(
   "setSymbols",
   {
-    exitEarly: ({ source }) => source.isWasm,
-    hasValue: ({ source }, { getState }) => hasSymbols(getState(), source),
-    getValue: ({ source }, { getState }) => getSymbols(getState(), source),
+    hasValue: ({ source }, { getState }) =>
+      source.isWasm || hasSymbols(getState(), source),
+    getValue: ({ source }, { getState }) =>
+      source.isWasm ? null : getSymbols(getState(), source),
     createKey: ({ source }) => source.id,
     action: ({ cx, source }, thunkArgs) => doSetSymbols(cx, source, thunkArgs),
   }
 );
--- a/devtools/client/debugger/src/reducers/sources.js
+++ b/devtools/client/debugger/src/reducers/sources.js
@@ -63,19 +63,16 @@ import type {
 } from "../types";
 import type { PendingSelectedLocation, Selector } from "./types";
 import type { Action, DonePromiseAction, FocusItem } from "../actions/types";
 import type { LoadSourceAction } from "../actions/types/SourceAction";
 import type { DebuggeeState } from "./debuggee";
 import { uniq } from "lodash";
 
 export type SourcesMap = { [SourceId]: Source };
-type SourcesContentMap = {
-  [SourceId]: AsyncValue<SourceContent> | null,
-};
 export type SourcesMapByThread = { [ThreadId]: SourcesMap };
 
 export type BreakpointPositionsMap = { [SourceId]: BreakpointPositions };
 type SourceActorMap = { [SourceId]: Array<SourceActorId> };
 
 type UrlsMap = { [string]: SourceId[] };
 type PlainUrlsMap = { [string]: string[] };
 
--- a/devtools/client/debugger/src/utils/memoizableAction.js
+++ b/devtools/client/debugger/src/utils/memoizableAction.js
@@ -1,33 +1,28 @@
 /* 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 type { ThunkArgs } from "../actions/types";
 
-export type MemoizedAction<
-  Args,
-  Result
-> = Args => ThunkArgs => Promise<?Result>;
+export type MemoizedAction<Args, Result> = Args => ThunkArgs => Promise<Result>;
 type MemoizableActionParams<Args, Result> = {
-  exitEarly?: (args: Args, thunkArgs: ThunkArgs) => boolean,
   hasValue: (args: Args, thunkArgs: ThunkArgs) => boolean,
   getValue: (args: Args, thunkArgs: ThunkArgs) => Result,
   createKey: (args: Args, thunkArgs: ThunkArgs) => string,
   action: (args: Args, thunkArgs: ThunkArgs) => Promise<Result>,
 };
 
 /*
  * memoizableActon is a utility for actions that should only be performed
  * once per key. It is useful for loading sources, parsing symbols ...
  *
- * @exitEarly - if true, do not attempt to perform the action
  * @hasValue - checks to see if the result is in the redux store
  * @getValue - gets the result from the redux store
  * @createKey - creates a key for the requests map
  * @action - kicks off the async work for the action
  *
  *
  * For Example
  *
@@ -44,25 +39,20 @@ type MemoizableActionParams<Args, Result
  */
 export function memoizeableAction<Args, Result>(
   name: string,
   {
     hasValue,
     getValue,
     createKey,
     action,
-    exitEarly,
   }: MemoizableActionParams<Args, Result>
 ): MemoizedAction<Args, Result> {
   const requests = new Map();
   return args => async (thunkArgs: ThunkArgs) => {
-    if (exitEarly && exitEarly(args, thunkArgs)) {
-      return;
-    }
-
     if (hasValue(args, thunkArgs)) {
       return getValue(args, thunkArgs);
     }
 
     const key = createKey(args, thunkArgs);
     if (!requests.has(key)) {
       requests.set(
         key,