Skip to content

Commit a10531a

Browse files
committed
Avoid creating a new array inside doResolve.
1 parent fd3bde2 commit a10531a

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)