Skip to content

Commit

Permalink
IndexSet
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jun 25, 2024
1 parent 8b7cfaf commit e78c389
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crates/turbopack-ecmascript/src/scope_hoisting/list_finder.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::collections::VecDeque;

use anyhow::Result;
use rustc_hash::{FxHashMap, FxHashSet};
use indexmap::IndexSet;
use rustc_hash::FxHashMap;
use turbo_tasks::Vc;
use turbopack_core::module::Module;

#[turbo_tasks::value]
pub struct Item {
pub shallow_list: Vc<Vec<Vc<Item>>>,
pub cond_loaded_modules: Vc<FxHashSet<Vc<Item>>>,
pub cond_loaded_modules: Vc<IndexSet<Vc<Item>>>,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand All @@ -19,15 +19,15 @@ enum ItemKind {

pub async fn find_list(entrypoints: Vc<Vec<Vc<Item>>>) -> Result<Vc<Vec<Vc<Item>>>> {
// Create an empty set X for items that have been processed.
let mut done = FxHashSet::default();
let mut done = IndexSet::default();
let mut queue = VecDeque::<(_, ItemKind)>::new();
queue.extend(entrypoints.await?.iter().map(|vc| (*vc, ItemKind::Enter)));

// Create an empty list L.
let mut list = vec![];

// Create an empty set S.
let mut set = FxHashSet::default();
let mut set = IndexSet::default();

while let Some((item, kind)) = queue.pop_front() {
// Add item to X.
Expand Down Expand Up @@ -68,8 +68,8 @@ pub async fn find_list(entrypoints: Vc<Vec<Vc<Item>>>) -> Result<Vc<Vec<Vc<Item>
// Set the item’s shallow list to L and the conditionally loaded modules
// to S.
let item = Item {
shallow_list: list,
cond_loaded_modules: set,
shallow_list: Vc::cell(list),
cond_loaded_modules: Vc::cell(set),
};

// Enqueue all items from S for processing
Expand Down

0 comments on commit e78c389

Please sign in to comment.