Skip to content

Commit 7b6834c

Browse files
perf(memory): avoid creating a new array inside doResolve
2 parents fd3bde2 + a10531a commit 7b6834c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/Resolver.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,11 @@ class Resolver {
692692
}
693693
newStack.add(stackEntry);
694694
} else {
695-
newStack = new Set([stackEntry]);
695+
// creating a set with new Set([item])
696+
// allocates a new array that has to be garbage collected
697+
// this is an EXTREMELY hot path, so let's avoid it
698+
newStack = new Set();
699+
newStack.add(stackEntry);
696700
}
697701
this.hooks.resolveStep.call(hook, request);
698702

0 commit comments

Comments
 (0)