Skip to content

Commit

Permalink
Made hash of substition not allocation memory.
Browse files Browse the repository at this point in the history
commit-id:2a6ce1b3
  • Loading branch information
orizi committed Oct 10, 2024
1 parent 9c11955 commit 63c8f9e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions crates/cairo-lang-semantic/src/substitution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use cairo_lang_defs::ids::{
use cairo_lang_diagnostics::{DiagnosticAdded, Maybe};
use cairo_lang_utils::ordered_hash_map::OrderedHashMap;
use cairo_lang_utils::{LookupIntern, extract_matches};
use itertools::{Itertools, zip_eq};
use itertools::zip_eq;

use crate::db::SemanticGroup;
use crate::expr::inference::{
Expand Down Expand Up @@ -58,11 +58,9 @@ impl GenericSubstitution {
}
pub fn new(generic_params: &[GenericParam], generic_args: &[GenericArgumentId]) -> Self {
GenericSubstitution {
param_to_arg: zip_eq(
generic_params.iter().map(|param| param.id()),
generic_args.iter().copied(),
)
.collect(),
param_to_arg: zip_eq(generic_params, generic_args)
.map(|(param, arg)| (param.id(), *arg))
.collect(),
self_impl: None,
}
}
Expand Down Expand Up @@ -91,7 +89,10 @@ impl DerefMut for GenericSubstitution {
#[allow(clippy::derived_hash_with_manual_eq)]
impl std::hash::Hash for GenericSubstitution {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.param_to_arg.iter().collect_vec().hash(state);
self.param_to_arg.len().hash(state);
for e in self.param_to_arg.iter() {
e.hash(state);
}
}
}

Expand Down

0 comments on commit 63c8f9e

Please sign in to comment.