Skip to content

Commit

Permalink
Performance tuning of the removeUnusedFSMState helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszmakuch committed Jan 4, 2019
1 parent 06999fe commit 3272db5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/utils/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ export const identityLens = lens(identity, identity);
export const nonEmptyArrow = arrow => arrow.some(([source, name]) => name != undefined)

export const removeUnusedFSMState = ({newFSMState, graph}) => {
const minimalFSMState = Object.keys(graph).reduce((FSMState, node) => {
let minimalFSMState = {};
Object.keys(graph).forEach(node => {
const existingState = newFSMState[node];
if (!existingState) return FSMState;
return {
...FSMState,
[node]: newFSMState[node]
};
}, {});
if (existingState) {
minimalFSMState[node] = newFSMState[node];
}
});
return minimalFSMState;
};

0 comments on commit 3272db5

Please sign in to comment.