Skip to content

Commit 5d4b7ac

Browse files
author
beicause
committed
perf: use promise.all in insertNode
1 parent 3bb631e commit 5d4b7ac

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/call.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ async function getCallNode(
1919
? 'vscode.provideOutgoingCalls'
2020
: 'vscode.provideIncomingCalls'
2121
const nodes = new Set<CallHierarchyNode>()
22-
const insertNode = async (node: CallHierarchyNode, depth=0) => {
22+
const insertNode = async (node: CallHierarchyNode, depth = 0) => {
2323
if (maxDepth > 0 && depth >= maxDepth) return
2424
output.appendLine('resolve: ' + node.item.name)
2525
nodes.add(node)
2626
const calls:
2727
| vscode.CallHierarchyOutgoingCall[]
2828
| vscode.CallHierarchyIncomingCall[] = await vscode.commands.executeCommand(
29-
command,
30-
node.item
31-
)
32-
for (const call of calls) {
29+
command,
30+
node.item
31+
)
32+
await Promise.all(calls.map(call => {
3333
const next =
3434
call instanceof vscode.CallHierarchyOutgoingCall
3535
? call.to
3636
: call.from
3737
if (ignore(next)) {
3838
output.appendLine('ignore it in config, ' + next.name)
39-
continue
39+
return null
4040
}
4141
let isSkip = false
4242
for (const n of nodes) {
@@ -46,11 +46,11 @@ async function getCallNode(
4646
isSkip = true
4747
}
4848
}
49-
if (isSkip) continue
49+
if (isSkip) return null
5050
const child = { item: next, children: [] }
5151
node.children.push(child)
52-
await insertNode(child, depth + 1)
53-
}
52+
return insertNode(child, depth + 1)
53+
}))
5454
}
5555
const graph = { item: entryItem, children: [] as CallHierarchyNode[] }
5656
await insertNode(graph)

0 commit comments

Comments
 (0)