Skip to content

Commit

Permalink
Avoid creating a new array inside doResolve.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdborton committed Jul 17, 2024
1 parent fd3bde2 commit a10531a
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 a10531a

Please sign in to comment.