From 8aaae15be826aa1412b5e5c80b053765e70fa180 Mon Sep 17 00:00:00 2001 From: Ziyang Hu Date: Fri, 9 Dec 2022 17:35:49 +0800 Subject: [PATCH] algo options may be huge, do not copy --- cozo-core/src/data/program.rs | 6 +++--- cozo-core/src/parse/query.rs | 6 +++--- cozo-core/src/query/stored.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cozo-core/src/data/program.rs b/cozo-core/src/data/program.rs index 46c94a1c..1b086e4c 100644 --- a/cozo-core/src/data/program.rs +++ b/cozo-core/src/data/program.rs @@ -203,7 +203,7 @@ impl InputInlineRulesOrAlgo { pub(crate) struct AlgoApply { pub(crate) algo: AlgoHandle, pub(crate) rule_args: Vec, - pub(crate) options: BTreeMap, Expr>, + pub(crate) options: Rc, Expr>>, pub(crate) head: Vec, 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, - pub(crate) options: BTreeMap, Expr>, + pub(crate) options: Rc, Expr>>, pub(crate) span: SourceSpan, pub(crate) arity: usize, pub(crate) algo_impl: Rc>, @@ -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 { diff --git a/cozo-core/src/parse/query.rs b/cozo-core/src/parse/query.rs index dc7a1777..12c47323 100644 --- a/cozo-core/src/parse/query.rs +++ b/cozo-core/src/parse/query.rs @@ -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(), diff --git a/cozo-core/src/query/stored.rs b/cozo-core/src/query/stored.rs index d4e8e360..9ad58ba9 100644 --- a/cozo-core/src/query/stored.rs +++ b/cozo-core/src/query/stored.rs @@ -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(),