mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-28 02:53:15 -04:00
perf(resolve-dependencies): avoid copying parentParentPkgs in resolvePeersOfNode (#6736)
This commit is contained in:
5
.changeset/brown-mayflies-sparkle.md
Normal file
5
.changeset/brown-mayflies-sparkle.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/resolve-dependencies": patch
|
||||
---
|
||||
|
||||
replacing object copying with a prototype chain, avoiding extra memory allocations in resolvePeersOfNode function
|
||||
@@ -289,16 +289,16 @@ function resolvePeersOfNode<T extends PartialResolvedPackage> (
|
||||
const children = node.children
|
||||
const parentPkgs = isEmpty(children)
|
||||
? parentParentPkgs
|
||||
: {
|
||||
...parentParentPkgs,
|
||||
...toPkgByName(
|
||||
: Object.assign(
|
||||
Object.create(parentParentPkgs),
|
||||
toPkgByName(
|
||||
Object.entries(children).map(([alias, nodeId]) => ({
|
||||
alias,
|
||||
node: ctx.dependenciesTree[nodeId],
|
||||
nodeId,
|
||||
}))
|
||||
),
|
||||
}
|
||||
)
|
||||
)
|
||||
const hit = ctx.peersCache.get(resolvedPackage.depPath)?.find((cache) =>
|
||||
cache.resolvedPeers
|
||||
.every(([name, cachedNodeId]) => {
|
||||
|
||||
Reference in New Issue
Block a user