Skip to content

Commit

Permalink
Avoid allocating new arrays when computing updated value in variables
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Newman <[email protected]>
  • Loading branch information
jerelmiller and benjamn committed May 18, 2023
1 parent 87f57b9 commit 785f68d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/link/remove-typename/removeTypenameFromVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ function maybeStripTypenameUsingConfig(
const variableDefinitions = getVariableDefinitions(query);

return Object.fromEntries(
Object.entries(variables).map(([key, value]) => {
Object.entries(variables).map((keyVal) => {
const [key, value] = keyVal;
const typename = variableDefinitions[key];
const typenameConfig = config[typename];

return [
key,
typenameConfig
? maybeStripTypename(value, typenameConfig)
: stripTypename(value),
];
keyVal[1] = typenameConfig
? maybeStripTypename(value, typenameConfig)
: stripTypename(value);

return keyVal;
})
);
}
Expand Down

0 comments on commit 785f68d

Please sign in to comment.