algo options may be huge, do not copy

main
Ziyang Hu 2 years ago
parent e09a1e4b09
commit 8aaae15be8

@ -203,7 +203,7 @@ impl InputInlineRulesOrAlgo {
pub(crate) struct AlgoApply {
pub(crate) algo: AlgoHandle,
pub(crate) rule_args: Vec<AlgoRuleArg>,
pub(crate) options: BTreeMap<SmartString<LazyCompact>, Expr>,
pub(crate) options: Rc<BTreeMap<SmartString<LazyCompact>, Expr>>,
pub(crate) head: Vec<Symbol>,
pub(crate) arity: usize,
pub(crate) span: SourceSpan,
@ -229,7 +229,7 @@ impl Debug for AlgoApply {
pub(crate) struct MagicAlgoApply {
pub(crate) algo: AlgoHandle,
pub(crate) rule_args: Vec<MagicAlgoRuleArg>,
pub(crate) options: BTreeMap<SmartString<LazyCompact>, Expr>,
pub(crate) options: Rc<BTreeMap<SmartString<LazyCompact>, Expr>>,
pub(crate) span: SourceSpan,
pub(crate) arity: usize,
pub(crate) algo_impl: Rc<Box<dyn AlgoImpl>>,
@ -465,7 +465,7 @@ impl Display for InputProgram {
}
write!(f, "{}", rule_arg)?;
}
for (k, v) in options {
for (k, v) in options.as_ref() {
if first {
first = false;
} else {

@ -214,7 +214,7 @@ pub(crate) fn parse_query(
algo: AlgoApply {
algo: handle,
rule_args: vec![],
options,
options: Rc::new(options),
head,
arity,
span,
@ -759,7 +759,7 @@ fn parse_algo_rule(
AlgoApply {
algo,
rule_args,
options,
options: Rc::new(options),
head,
arity,
span: args_list_span,
@ -797,7 +797,7 @@ fn make_empty_const_rule(prog: &mut InputProgram, bindings: &[Symbol]) {
name: Symbol::new("Constant", Default::default()),
},
rule_args: vec![],
options,
options: Rc::new(options),
head: bindings.to_vec(),
arity: bindings.len(),
span: Default::default(),

@ -438,7 +438,7 @@ fn make_const_rule(
name: Symbol::new("Constant", Default::default()),
},
rule_args: vec![],
options,
options: Rc::new(options),
head: bindings,
arity: bindings_arity,
span: Default::default(),

Loading…
Cancel
Save