-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented module ID global optimization using GlobalInformation.
- Loading branch information
Lichu Acuña
committed
Aug 6, 2024
1 parent
721c53b
commit 171aaa9
Showing
5 changed files
with
45 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
use std::collections::HashMap; | ||
|
||
use anyhow::Result; | ||
use turbo_tasks::{ValueToString, Vc}; | ||
|
||
use super::ModuleId; | ||
use crate::ident::AssetIdent; | ||
|
||
#[turbo_tasks::value] | ||
#[derive(Clone, Debug)] | ||
pub struct GlobalInformation {} | ||
pub struct GlobalInformation { | ||
pub module_id_map: HashMap<AssetIdent, ModuleId>, | ||
} | ||
|
||
impl GlobalInformation { | ||
pub async fn get_module_id(&self, asset_ident: Vc<AssetIdent>) -> Result<Vc<ModuleId>> { | ||
let ident_str = asset_ident.to_string().await?; | ||
let ident = asset_ident.await?; | ||
let hashed_module_id = self.module_id_map.get(&ident); | ||
if let Some(hashed_module_id) = hashed_module_id { | ||
dbg!("Hashed module ID found", &ident_str, hashed_module_id); | ||
return Ok(hashed_module_id.clone().cell()); | ||
} | ||
dbg!("Hashed module ID not found", &ident_str); | ||
return Ok(ModuleId::String(ident_str.clone_value()).cell()); | ||
} | ||
} | ||
|
||
#[turbo_tasks::value(transparent)] | ||
pub struct OptionGlobalInformation(Option<GlobalInformation>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters