Skip to content

Commit

Permalink
Fix eval_lit performance bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Fischman committed Oct 16, 2024
1 parent 43de12f commit 840308a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,12 +677,13 @@ impl EGraph {
}

pub fn eval_lit(&self, lit: &Literal) -> Value {
let any_sort = self.type_info.infer_literal(lit).as_arc_any();
match lit {
Literal::Int(i) => i.store(&self.type_info.get_sort_nofail()).unwrap(),
Literal::F64(f) => f.store(&self.type_info.get_sort_nofail()).unwrap(),
Literal::String(s) => s.store(&self.type_info.get_sort_nofail()).unwrap(),
Literal::Unit => ().store(&self.type_info.get_sort_nofail()).unwrap(),
Literal::Bool(b) => b.store(&self.type_info.get_sort_nofail()).unwrap(),
Literal::Int(i) => i.store(&any_sort.downcast().unwrap()).unwrap(),
Literal::F64(f) => f.store(&any_sort.downcast().unwrap()).unwrap(),
Literal::String(s) => s.store(&any_sort.downcast().unwrap()).unwrap(),
Literal::Unit => ().store(&any_sort.downcast().unwrap()).unwrap(),
Literal::Bool(b) => b.store(&any_sort.downcast().unwrap()).unwrap(),
}
}

Expand Down

0 comments on commit 840308a

Please sign in to comment.