Skip to content

Commit aba922e

Browse files
committed
split completions into a tree
1 parent 038b2cd commit aba922e

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

turbopack/crates/turbo-tasks/src/completion.rs

+21-9
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,26 @@ impl Completions {
6060
/// Merges the list of completions into one.
6161
#[turbo_tasks::function]
6262
pub async fn completed(&self) -> anyhow::Result<Vc<Completion>> {
63-
self.0
64-
.iter()
65-
.map(|&c| async move {
66-
c.await?;
67-
Ok(())
68-
})
69-
.try_join()
70-
.await?;
71-
Ok(Completion::new())
63+
if self.0.len() > 100 {
64+
let mid = self.0.len() / 2;
65+
let (left, right) = self.0.split_at(mid);
66+
let left = Vc::<Completions>::cell(left.to_vec());
67+
let right = Vc::<Completions>::cell(right.to_vec());
68+
let left = left.completed();
69+
let right = right.completed();
70+
left.await?;
71+
right.await?;
72+
Ok(Completion::new())
73+
} else {
74+
self.0
75+
.iter()
76+
.map(|&c| async move {
77+
c.await?;
78+
Ok(())
79+
})
80+
.try_join()
81+
.await?;
82+
Ok(Completion::new())
83+
}
7284
}
7385
}

0 commit comments

Comments
 (0)