Skip to content

Commit 8aaae15

Browse files
committed
algo options may be huge, do not copy
1 parent e09a1e4 commit 8aaae15

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

cozo-core/src/data/program.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl InputInlineRulesOrAlgo {
203203
pub(crate) struct AlgoApply {
204204
pub(crate) algo: AlgoHandle,
205205
pub(crate) rule_args: Vec<AlgoRuleArg>,
206-
pub(crate) options: BTreeMap<SmartString<LazyCompact>, Expr>,
206+
pub(crate) options: Rc<BTreeMap<SmartString<LazyCompact>, Expr>>,
207207
pub(crate) head: Vec<Symbol>,
208208
pub(crate) arity: usize,
209209
pub(crate) span: SourceSpan,
@@ -229,7 +229,7 @@ impl Debug for AlgoApply {
229229
pub(crate) struct MagicAlgoApply {
230230
pub(crate) algo: AlgoHandle,
231231
pub(crate) rule_args: Vec<MagicAlgoRuleArg>,
232-
pub(crate) options: BTreeMap<SmartString<LazyCompact>, Expr>,
232+
pub(crate) options: Rc<BTreeMap<SmartString<LazyCompact>, Expr>>,
233233
pub(crate) span: SourceSpan,
234234
pub(crate) arity: usize,
235235
pub(crate) algo_impl: Rc<Box<dyn AlgoImpl>>,
@@ -465,7 +465,7 @@ impl Display for InputProgram {
465465
}
466466
write!(f, "{}", rule_arg)?;
467467
}
468-
for (k, v) in options {
468+
for (k, v) in options.as_ref() {
469469
if first {
470470
first = false;
471471
} else {

cozo-core/src/parse/query.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub(crate) fn parse_query(
214214
algo: AlgoApply {
215215
algo: handle,
216216
rule_args: vec![],
217-
options,
217+
options: Rc::new(options),
218218
head,
219219
arity,
220220
span,
@@ -759,7 +759,7 @@ fn parse_algo_rule(
759759
AlgoApply {
760760
algo,
761761
rule_args,
762-
options,
762+
options: Rc::new(options),
763763
head,
764764
arity,
765765
span: args_list_span,
@@ -797,7 +797,7 @@ fn make_empty_const_rule(prog: &mut InputProgram, bindings: &[Symbol]) {
797797
name: Symbol::new("Constant", Default::default()),
798798
},
799799
rule_args: vec![],
800-
options,
800+
options: Rc::new(options),
801801
head: bindings.to_vec(),
802802
arity: bindings.len(),
803803
span: Default::default(),

cozo-core/src/query/stored.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ fn make_const_rule(
438438
name: Symbol::new("Constant", Default::default()),
439439
},
440440
rule_args: vec![],
441-
options,
441+
options: Rc::new(options),
442442
head: bindings,
443443
arity: bindings_arity,
444444
span: Default::default(),

0 commit comments

Comments
 (0)