Commit 53757f3e authored by Benjamin Woodruff's avatar Benjamin Woodruff

WIP: Turbopack: Replace SliceMap with FrozenMap

parent c15f8ecd
......@@ -9673,6 +9673,7 @@ dependencies = [
"tokio",
"tracing",
"turbo-bincode",
"turbo-frozenmap",
"turbo-prehash",
"turbo-rcstr",
"turbo-tasks",
......@@ -9796,6 +9797,7 @@ dependencies = [
"tracing",
"turbo-bincode",
"turbo-esregex",
"turbo-frozenmap",
"turbo-rcstr",
"turbo-tasks",
"turbo-tasks-backend",
......@@ -10014,6 +10016,7 @@ dependencies = [
"serde",
"serde_json",
"tracing",
"turbo-frozenmap",
"turbo-rcstr",
"turbo-tasks",
"turbo-tasks-fs",
......
......@@ -138,8 +138,6 @@ pub use crate::{
},
};
pub type SliceMap<K, V> = Box<[(K, V)]>;
pub type FxIndexSet<T> = indexmap::IndexSet<T, BuildHasherDefault<FxHasher>>;
pub type FxIndexMap<K, V> = indexmap::IndexMap<K, V, BuildHasherDefault<FxHasher>>;
pub type FxDashMap<K, V> = dashmap::DashMap<K, V, BuildHasherDefault<FxHasher>>;
......
......@@ -39,6 +39,7 @@ swc_sourcemap = { workspace = true }
swc_core = { workspace = true, features = ["ecma_preset_env", "common"] }
tracing = { workspace = true }
turbo-bincode = { workspace = true }
turbo-frozenmap = { workspace = true }
turbo-prehash = { workspace = true }
turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true }
......
......@@ -48,6 +48,7 @@ tokio = { workspace = true }
tracing = { workspace = true }
turbo-bincode = { workspace = true }
turbo-esregex = { workspace = true }
turbo-frozenmap = { workspace = true }
turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true }
turbo-tasks-fs = { workspace = true }
......
......@@ -9,6 +9,7 @@ use swc_core::{
},
quote,
};
use turbo_frozenmap::FrozenMap;
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, ValueToString, Vc};
use turbo_tasks_fs::FileSystemPath;
......@@ -434,10 +435,10 @@ impl ModuleReference for EsmAssetReference {
.await?
{
return Ok(ModuleResolveResult {
primary: Box::new([(
primary: FrozenMap::from_unique_sorted_box(Box::new([(
RequestKey::default(),
ModuleResolveResultItem::Ignore,
)]),
)])),
affecting_sources: Default::default(),
}
.cell());
......
......@@ -419,7 +419,7 @@ impl PatternMapping {
))
.cell()),
1 if !request.request_pattern().await?.has_dynamic_parts() => {
let resolve_item = &result.primary.first().unwrap().1;
let resolve_item = &result.primary.first_key_value().unwrap().1;
let single_pattern_mapping =
to_single_pattern_mapping(origin, chunking_context, resolve_item, resolve_type)
.await?;
......
......@@ -14,13 +14,14 @@ workspace = true
[dependencies]
anyhow = { workspace = true }
next-taskless = { workspace = true }
regex = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tracing = { workspace = true }
turbo-frozenmap = { workspace = true }
turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true }
turbo-tasks-fs = { workspace = true }
turbopack-core = { workspace = true }
next-taskless = { workspace = true }
......@@ -317,7 +317,7 @@ async fn resolve_node_gyp_build_files(
)
.await?;
if let Some((_, ResolveResultItem::Source(source))) =
resolved_prebuilt_file.primary.first()
resolved_prebuilt_file.primary.first_key_value()
{
resolved.insert(format!("build/Release/{name}.node").into(), *source);
if collect_affecting_sources {
......
......@@ -2,6 +2,7 @@ use std::mem::take;
use anyhow::Result;
use serde_json::Value as JsonValue;
use turbo_frozenmap::FrozenMap;
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{FxIndexMap, ResolvedVc, ValueDefault, Vc, fxindexset};
use turbo_tasks_fs::{FileContent, FileJsonContent, FileSystemPath, FileSystemPathOption};
......@@ -478,12 +479,11 @@ pub async fn type_resolve(
#[turbo_tasks::function]
pub async fn as_typings_result(result: Vc<ModuleResolveResult>) -> Result<Vc<ModuleResolveResult>> {
let mut result = result.owned().await?;
result.primary = IntoIterator::into_iter(take(&mut result.primary))
.map(|(mut k, v)| {
k.conditions.insert("types".to_string(), true);
(k, v)
})
.collect();
let mut primary = Box::<[_]>::from(take(&mut result.primary));
for (request_key, _v) in &mut primary {
request_key.conditions.insert("types".to_string(), true);
}
result.primary = FrozenMap::from_overlapping_vec(primary.into_vec());
Ok(result.cell())
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment