Skip to content

Commit

Permalink
Also cache names of other builtin sorts
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Fischman committed Oct 16, 2024
1 parent f04694a commit 8ae1427
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/sort/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ use super::*;
#[derive(Debug)]
pub struct BoolSort;

lazy_static! {
static ref BOOL_SORT_NAME: Symbol = "bool".into();
}

impl Sort for BoolSort {
fn name(&self) -> Symbol {
"bool".into()
*BOOL_SORT_NAME
}

fn as_arc_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync + 'static> {
Expand Down
6 changes: 5 additions & 1 deletion src/sort/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ use ordered_float::OrderedFloat;
#[derive(Debug)]
pub struct F64Sort;

lazy_static! {
static ref F64_SORT_NAME: Symbol = "f64".into();
}

impl Sort for F64Sort {
fn name(&self) -> Symbol {
"f64".into()
*F64_SORT_NAME
}

fn as_arc_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync + 'static> {
Expand Down
3 changes: 2 additions & 1 deletion src/sort/rational.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{ast::Literal, util::IndexSet};
use super::*;

lazy_static! {
static ref RATIONAL_SORT_NAME: Symbol = "Rational".into();
static ref RATS: Mutex<IndexSet<R>> = Default::default();
}

Expand All @@ -16,7 +17,7 @@ pub struct RationalSort;

impl Sort for RationalSort {
fn name(&self) -> Symbol {
"Rational".into()
*RATIONAL_SORT_NAME
}

fn as_arc_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync + 'static> {
Expand Down
6 changes: 5 additions & 1 deletion src/sort/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ use super::*;
#[derive(Debug)]
pub struct StringSort;

lazy_static! {
static ref STRING_SORT_NAME: Symbol = "String".into();
}

impl Sort for StringSort {
fn name(&self) -> Symbol {
"String".into()
*STRING_SORT_NAME
}

fn as_arc_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync + 'static> {
Expand Down
6 changes: 5 additions & 1 deletion src/sort/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ use crate::{ast::Literal, constraint::AllEqualTypeConstraint, ArcSort, Primitive
#[derive(Debug)]
pub struct UnitSort;

lazy_static! {
static ref UNIT_SORT_NAME: Symbol = "Unit".into();
}

impl Sort for UnitSort {
fn name(&self) -> Symbol {
"Unit".into()
*UNIT_SORT_NAME
}

fn as_arc_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync + 'static> {
Expand Down

0 comments on commit 8ae1427

Please sign in to comment.