Skip to content

Commit

Permalink
split completions into a tree
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Sep 26, 2024
1 parent 7cf88a6 commit 85c1e54
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions turbopack/crates/turbo-tasks/src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,26 @@ impl Completions {
/// Merges the list of completions into one.
#[turbo_tasks::function]
pub async fn completed(&self) -> anyhow::Result<Vc<Completion>> {
self.0
.iter()
.map(|&c| async move {
c.await?;
Ok(())
})
.try_join()
.await?;
Ok(Completion::new())
if self.0.len() > 100 {
let mid = self.0.len() / 2;
let (left, right) = self.0.split_at(mid);
let left = Vc::<Completions>::cell(left.to_vec());
let right = Vc::<Completions>::cell(right.to_vec());
let left = left.completed();
let right = right.completed();
left.await?;
right.await?;
Ok(Completion::new())
} else {
self.0
.iter()
.map(|&c| async move {
c.await?;
Ok(())
})
.try_join()
.await?;
Ok(Completion::new())
}
}
}

0 comments on commit 85c1e54

Please sign in to comment.