From 785f68d45cdebb0b20c5952fceb9e6391991c8ce Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 18 May 2023 10:00:37 -0600 Subject: [PATCH] Avoid allocating new arrays when computing updated value in variables Co-authored-by: Ben Newman --- .../remove-typename/removeTypenameFromVariables.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/link/remove-typename/removeTypenameFromVariables.ts b/src/link/remove-typename/removeTypenameFromVariables.ts index 8c89c2bad2e..fe0ea6b49ac 100644 --- a/src/link/remove-typename/removeTypenameFromVariables.ts +++ b/src/link/remove-typename/removeTypenameFromVariables.ts @@ -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; }) ); }