Commit 74575c6c authored by Jeff Smits's avatar Jeff Smits

Doubling down on the constructor caching

parent 59f31e06
This diff is collapsed.
......@@ -158,8 +158,7 @@ impl<'d, 'f : 'd> Eval<'d, 'f> for preprocess::Strategy {
let strategy_name = context.get_term(term_name)?;
let strategy_name = get_string(&*b(&strategy_name)).ok_or_else(|| {
Error::UndefinedStrategy(format!(
"Invocation target is invalid \
(cannot be evaluated): {}",
"Invocation target is invalid (cannot be evaluated): {}",
strategy_name
))
})?;
......
......@@ -295,6 +295,7 @@ impl TryFrom<ctree::PreTerm> for BuildTerm {
}
impl BuildTerm {
#[inline]
pub fn build<'d, 'f : 'd>(&self, context: &MutContext<'d, 'f>) -> Result<ATermRef> {
self.build_with_annos(context, None)
}
......@@ -349,9 +350,10 @@ impl BuildTerm {
} else if s == "Nil" && t.is_empty() {
Ok(context.factory.list(iter::empty()))
} else {
let cons = context.factory.get_known_cons(s).unwrap_or_else(|| s.clone().into());
Ok(context.factory.with_annos(
context.factory.t_application(
&s.clone().into(),
&cons,
t.into_iter(),
),
annos.unwrap_or_default(),
......@@ -366,12 +368,13 @@ impl BuildTerm {
))?;
if let Some(s) = get_string(&*cons) {
let string = context.factory.application(&s.clone().into(), ::std::iter::empty());
let cons = context.factory.get_known_cons(&s).unwrap_or_else(|| s.clone().into());
let string = context.factory.application(&cons, ::std::iter::empty());
if get_string(&*string).is_some() {
Ok(string)
} else {
let application =
context.factory.t_application(&s.into(), children.iter().cloned());
context.factory.t_application(&cons, children.iter().cloned());
Ok(context.factory.with_annos(
application,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment