Skip to content

Commit f866f92

Browse files
committed
Avoid creating new objects/arrays in selectors
1 parent 121537a commit f866f92

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

ui/frontend/selectors/index.ts

+18-15
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,22 @@ export const getAdvancedOptionsSet = createSelector(
188188

189189
export const hasProperties = (obj: {}) => Object.values(obj).some(val => !!val);
190190

191-
const getOutputs = (state: State) => [
192-
state.output.assembly,
193-
state.output.clippy,
194-
state.output.execute,
195-
state.output.format,
196-
state.output.gist,
197-
state.output.llvmIr,
198-
state.output.mir,
199-
state.output.hir,
200-
state.output.miri,
201-
state.output.macroExpansion,
202-
state.output.wasm,
203-
];
191+
const getOutputs = createSelector(
192+
(state: State) => state,
193+
(state) => [
194+
state.output.assembly,
195+
state.output.clippy,
196+
state.output.execute,
197+
state.output.format,
198+
state.output.gist,
199+
state.output.llvmIr,
200+
state.output.mir,
201+
state.output.hir,
202+
state.output.miri,
203+
state.output.macroExpansion,
204+
state.output.wasm,
205+
],
206+
);
204207

205208
export const getSomethingToShow = createSelector(
206209
getOutputs,
@@ -479,7 +482,7 @@ export const executeRequestPayloadSelector = createSelector(
479482
channelSelector,
480483
(state: State) => state.configuration,
481484
getBacktraceSet,
482-
(_state: State, { crateType, tests }: { crateType: string, tests: boolean }) => ({ crateType, tests }),
485+
(_state: State, args: { crateType: string, tests: boolean }) => args,
483486
(code, channel, configuration, backtrace, { crateType, tests }) => ({
484487
channel,
485488
mode: configuration.mode,
@@ -498,7 +501,7 @@ export const compileRequestPayloadSelector = createSelector(
498501
getCrateType,
499502
runAsTest,
500503
getBacktraceSet,
501-
(_state: State, { target }: { target: string }) => ({ target }),
504+
(_state: State, args: { target: string }) => args,
502505
(code, channel, configuration, crateType, tests, backtrace, { target }) => ({
503506
channel,
504507
mode: configuration.mode,

0 commit comments

Comments
 (0)