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

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

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

Loading…
Cancel
Save