Commit 4db16c37 authored by Tobias Koppers's avatar Tobias Koppers

Use Vc::contains_key for single-item availability checks

Replace the pattern of awaiting the full AvailableModulesSet and calling
.contains() with Vc::contains_key(), which only depends on the queried
key rather than the full set value. Also remove internal implementation
comments from available_modules.rs.
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
parent a27b2581
...@@ -51,11 +51,6 @@ impl From<ChunkableModuleOrBatch> for AvailableModuleItem { ...@@ -51,11 +51,6 @@ impl From<ChunkableModuleOrBatch> for AvailableModuleItem {
/// A flat set of modules/items that are already available in the current chunk /// A flat set of modules/items that are already available in the current chunk
/// group context and therefore do not need to be included again. /// group context and therefore do not need to be included again.
///
/// This is a `#[turbo_tasks::value(transparent)]` wrapping
/// `FxIndexSet<AvailableModuleItem>`. Awaiting a `Vc<AvailableModulesSet>`
/// yields a `ReadRef` whose `Deref` target is the inner `FxIndexSet`, and
/// `Vc::cell` takes an `FxIndexSet<AvailableModuleItem>` directly.
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct AvailableModulesSet( pub struct AvailableModulesSet(
...@@ -70,9 +65,6 @@ impl AvailableModulesSet { ...@@ -70,9 +65,6 @@ impl AvailableModulesSet {
self: ResolvedVc<Self>, self: ResolvedVc<Self>,
extra: Vc<AvailableModulesSet>, extra: Vc<AvailableModulesSet>,
) -> Result<Vc<Self>> { ) -> Result<Vc<Self>> {
// For transparent Vc, .await? yields a ReadRef whose Deref target is the
// inner FxIndexSet<AvailableModuleItem>. Explicitly dereferencing with `*`
// gives the inner set.
let base = self.await?; let base = self.await?;
let extra = extra.await?; let extra = extra.await?;
let mut merged = (*base).clone(); let mut merged = (*base).clone();
...@@ -109,7 +101,6 @@ impl AvailableModulesSet { ...@@ -109,7 +101,6 @@ impl AvailableModulesSet {
impl AvailableModulesSet { impl AvailableModulesSet {
/// Returns true if this set contains the given item. /// Returns true if this set contains the given item.
pub fn contains(&self, item: &AvailableModuleItem) -> bool { pub fn contains(&self, item: &AvailableModuleItem) -> bool {
// Self is #[repr(transparent)] over FxIndexSet; field .0 is accessible here.
self.0.contains(item) self.0.contains(item)
} }
} }
...@@ -70,8 +70,8 @@ impl AsyncLoaderModule { ...@@ -70,8 +70,8 @@ impl AsyncLoaderModule {
if let Some(chunkable_module_or_batch) = if let Some(chunkable_module_or_batch) =
ChunkableModuleOrBatch::from_module_or_batch(module_or_batch) ChunkableModuleOrBatch::from_module_or_batch(module_or_batch)
&& chunk_items && chunk_items
.contains_key(&AvailableModuleItem::from(chunkable_module_or_batch))
.await? .await?
.contains(&AvailableModuleItem::from(chunkable_module_or_batch))
{ {
return Ok(OutputAssetsWithReferenced { return Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(vec![]), assets: ResolvedVc::cell(vec![]),
......
...@@ -86,8 +86,8 @@ impl ManifestAsyncModule { ...@@ -86,8 +86,8 @@ impl ManifestAsyncModule {
if let Some(chunkable_module_or_batch) = if let Some(chunkable_module_or_batch) =
ChunkableModuleOrBatch::from_module_or_batch(module_or_batch) ChunkableModuleOrBatch::from_module_or_batch(module_or_batch)
&& chunk_items && chunk_items
.contains_key(&AvailableModuleItem::from(chunkable_module_or_batch))
.await? .await?
.contains(&AvailableModuleItem::from(chunkable_module_or_batch))
{ {
return Ok(OutputAssetsWithReferenced { return Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(vec![]), assets: ResolvedVc::cell(vec![]),
......
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