Skip to content

Commit

Permalink
avoid duplicates in primary_modules (vercel/turborepo#8509)
Browse files Browse the repository at this point in the history
### Description

cheaper graph traversal as we don't have to process these modules
multiple times

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->
  • Loading branch information
sokra authored Jun 17, 2024
1 parent cdf59ea commit 61ad799
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/turbopack-core/src/reference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ pub async fn referenced_modules_and_affecting_sources(
/// [Module]: crate::module::Module
#[turbo_tasks::function]
pub async fn primary_referenced_modules(module: Vc<Box<dyn Module>>) -> Result<Vc<Modules>> {
let mut set = HashSet::new();
let modules = module
.references()
.await?
Expand All @@ -192,6 +193,7 @@ pub async fn primary_referenced_modules(module: Vc<Box<dyn Module>>) -> Result<V
.await?
.into_iter()
.flatten()
.filter(|&module| set.insert(module))
.collect();
Ok(Vc::cell(modules))
}
Expand Down

0 comments on commit 61ad799

Please sign in to comment.