-
-
Notifications
You must be signed in to change notification settings - Fork 613
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
449 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use rspack_collections::IdentifierMap; | ||
use rspack_hash::RspackHashDigest; | ||
|
||
use crate::{ModuleIdentifier, RuntimeSpec, RuntimeSpecMap}; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct CgmHashArtifact { | ||
module_to_hashes: IdentifierMap<RuntimeSpecMap<RspackHashDigest>>, | ||
} | ||
|
||
impl CgmHashArtifact { | ||
pub fn is_empty(&self) -> bool { | ||
self.module_to_hashes.is_empty() | ||
} | ||
|
||
pub fn get(&self, module: &ModuleIdentifier, runtime: &RuntimeSpec) -> Option<&RspackHashDigest> { | ||
let hashes = self.module_to_hashes.get(module)?; | ||
hashes.get(runtime) | ||
} | ||
|
||
pub fn set_hashes(&mut self, module: ModuleIdentifier, hashes: RuntimeSpecMap<RspackHashDigest>) { | ||
self.module_to_hashes.insert(module, hashes); | ||
} | ||
|
||
pub fn remove(&mut self, module: &ModuleIdentifier) -> Option<RuntimeSpecMap<RspackHashDigest>> { | ||
self.module_to_hashes.remove(module) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
crates/rspack_core/src/artifacts/cgm_runtime_requirement_artifact.rs
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use rspack_collections::IdentifierMap; | ||
|
||
use crate::{ModuleIdentifier, RuntimeGlobals, RuntimeSpec, RuntimeSpecMap}; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct CgmRuntimeRequirementsArtifact { | ||
module_to_runtime_requirements: IdentifierMap<RuntimeSpecMap<RuntimeGlobals>>, | ||
} | ||
|
||
impl CgmRuntimeRequirementsArtifact { | ||
pub fn is_empty(&self) -> bool { | ||
self.module_to_runtime_requirements.is_empty() | ||
} | ||
|
||
pub fn get(&self, module: &ModuleIdentifier, runtime: &RuntimeSpec) -> Option<&RuntimeGlobals> { | ||
let requirements = self.module_to_runtime_requirements.get(module)?; | ||
requirements.get(runtime) | ||
} | ||
|
||
pub fn set_runtime_requirements( | ||
&mut self, | ||
module: ModuleIdentifier, | ||
runtime_requirements_map: RuntimeSpecMap<RuntimeGlobals>, | ||
) { | ||
self | ||
.module_to_runtime_requirements | ||
.insert(module, runtime_requirements_map); | ||
} | ||
|
||
pub fn remove(&mut self, module: &ModuleIdentifier) -> Option<RuntimeSpecMap<RuntimeGlobals>> { | ||
self.module_to_runtime_requirements.remove(module) | ||
} | ||
} |
Oops, something went wrong.