Using rc we now get code that runs much faster and
can run jpg contract with no inputs
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::ast::{Name, Term};
|
||||
use crate::program_builder::WithTerm;
|
||||
|
||||
@@ -30,8 +32,8 @@ impl<T: WithTerm> WithTerm for ApplyBuilderArgument<T> {
|
||||
|
||||
fn next(self, term: Term<Name>) -> Self::Next {
|
||||
let term = Term::Apply {
|
||||
function: Box::new(self.function),
|
||||
argument: Box::new(term),
|
||||
function: Rc::new(self.function),
|
||||
argument: Rc::new(term),
|
||||
};
|
||||
self.outer.next(term)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::ast::{Name, Term};
|
||||
use crate::program_builder::WithTerm;
|
||||
|
||||
@@ -9,7 +11,7 @@ impl<T: WithTerm> WithTerm for DelayBuilder<T> {
|
||||
type Next = T::Next;
|
||||
|
||||
fn next(self, term: Term<Name>) -> Self::Next {
|
||||
let term = Term::Delay(Box::new(term));
|
||||
let term = Term::Delay(Rc::new(term));
|
||||
self.outer.next(term)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::ast::{Name, Term};
|
||||
use crate::program_builder::WithTerm;
|
||||
|
||||
@@ -9,7 +11,7 @@ impl<T: WithTerm> WithTerm for ForceBuilder<T> {
|
||||
type Next = T::Next;
|
||||
|
||||
fn next(self, term: Term<Name>) -> Self::Next {
|
||||
let term = Term::Force(Box::new(term));
|
||||
let term = Term::Force(Rc::new(term));
|
||||
self.outer.next(term)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::ast::{Name, Term};
|
||||
use crate::program_builder::WithTerm;
|
||||
|
||||
@@ -12,7 +14,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,
|
||||
body: Box::new(term),
|
||||
body: Rc::new(term),
|
||||
};
|
||||
self.outer.next(term)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user