feat: use Rc for more things, fib_iter runs almost 3 seconds faster now

This commit is contained in:
rvcas
2023-01-31 03:30:45 -05:00
committed by Lucas
parent eda3194cf0
commit c8efe60843
15 changed files with 1789 additions and 1110 deletions

View File

@@ -3,27 +3,27 @@ use crate::program_builder::WithTerm;
pub trait WithConstant: WithTerm {
fn with_int(self, int: i128) -> Self::Next {
let term = Term::Constant(Constant::Integer(int));
let term = Term::Constant(Constant::Integer(int).into());
self.next(term)
}
fn with_byte_string(self, bytes: Vec<u8>) -> Self::Next {
let term = Term::Constant(Constant::ByteString(bytes));
let term = Term::Constant(Constant::ByteString(bytes).into());
self.next(term)
}
fn with_string(self, string: String) -> Self::Next {
let term = Term::Constant(Constant::String(string));
let term = Term::Constant(Constant::String(string).into());
self.next(term)
}
fn with_unit(self) -> Self::Next {
let term = Term::Constant(Constant::Unit);
let term = Term::Constant(Constant::Unit.into());
self.next(term)
}
fn with_bool(self, bool: bool) -> Self::Next {
let term = Term::Constant(Constant::Bool(bool));
let term = Term::Constant(Constant::Bool(bool).into());
self.next(term)
}
}

View File

@@ -13,7 +13,7 @@ impl<T: WithTerm> WithTerm for LambdaBuilder<T> {
fn next(self, term: Term<Name>) -> Self::Next {
let term = Term::Lambda {
parameter_name: self.parameter_name,
parameter_name: self.parameter_name.into(),
body: Rc::new(term),
};
self.outer.next(term)

View File

@@ -4,7 +4,7 @@ use crate::program_builder::WithTerm;
pub trait WithVar: WithTerm {
fn with_var(self, name_str: &str) -> Self::Next {
let name = self.get_name(name_str);
let term = Term::Var(name);
let term = Term::Var(name.into());
self.next(term)
}
}