Bug 1541631 - Part 5: Remove exitEarly option from memoizableAction since it isn't needed. r=jlast
authorLogan Smyth <loganfsmyth@gmail.com>
Thu, 15 Aug 2019 21:45:50 +0000
changeset 488392 780781260eaa9a306db882eddaca6be1f5b72e43
parent 488391 c3131097b7c34fdb8606bab7d6d4972dca632249
child 488393 1e83299913b542621054db8783390cba8674d973
push id36443
push userccoroiu@mozilla.com
push dateFri, 16 Aug 2019 09:48:15 +0000
treeherdermozilla-central@5d4cbfe103bb [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,