pass by reference

This commit is contained in:
alpharush 2022-12-25 21:14:12 -06:00
parent c86e54b9ea
commit b416c1927f
1 changed files with 3 additions and 3 deletions

View File

@ -37,7 +37,7 @@ pub struct CompilationUnitId(u64);
impl CompilationUnitId { impl CompilationUnitId {
/// Create a unique id for each compilation unit based on compiler version and settings /// Create a unique id for each compilation unit based on compiler version and settings
pub fn new(version: Version, solc_config: SolcConfig) -> Self { pub fn new(version: &Version, solc_config: &SolcConfig) -> Self {
let mut hasher = hash_map::DefaultHasher::new(); let mut hasher = hash_map::DefaultHasher::new();
version.hash(&mut hasher); version.hash(&mut hasher);
solc_config.hash(&mut hasher); solc_config.hash(&mut hasher);
@ -654,7 +654,7 @@ impl<'a, T: ArtifactOutput> ArtifactsCacheInner<'a, T> {
.unwrap_or_default(), .unwrap_or_default(),
content_hash: source.content_hash(), content_hash: source.content_hash(),
source_name: utils::source_name(file, self.project.root()).into(), source_name: utils::source_name(file, self.project.root()).into(),
compilation_unit: CompilationUnitId::new(version, self.project.solc_config.clone()), compilation_unit: CompilationUnitId::new(&version, &self.project.solc_config),
imports, imports,
version_requirement: self.edges.version_requirement(file).map(|v| v.to_string()), version_requirement: self.edges.version_requirement(file).map(|v| v.to_string()),
// artifacts remain empty until we received the compiler output // artifacts remain empty until we received the compiler output
@ -674,7 +674,7 @@ impl<'a, T: ArtifactOutput> ArtifactsCacheInner<'a, T> {
solc_config: SolcConfig, solc_config: SolcConfig,
version: Version, version: Version,
) { ) {
let id = CompilationUnitId::new(version.clone(), solc_config.clone()); let id = CompilationUnitId::new(&version, &solc_config);
if let Some(CompilationUnit { source_units, .. }) = if let Some(CompilationUnit { source_units, .. }) =
self.cache.compilation_units.get_mut(&id) self.cache.compilation_units.get_mut(&id)
{ {