Skip to content

Commit

Permalink
perf(memory): avoid creating a new array inside doResolve
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored Jul 17, 2024
2 parents fd3bde2 + a10531a commit 7b6834c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,11 @@ class Resolver {
}
newStack.add(stackEntry);
} else {
newStack = new Set([stackEntry]);
// creating a set with new Set([item])
// allocates a new array that has to be garbage collected
// this is an EXTREMELY hot path, so let's avoid it
newStack = new Set();
newStack.add(stackEntry);
}
this.hooks.resolveStep.call(hook, request);

Expand Down

0 comments on commit 7b6834c

Please sign in to comment.