+4
-6
src/execution/lazy.rs
+4
-6
src/execution/lazy.rs
···
65
65
let mut locals = VariableMap::new();
66
66
let mut store = LazyStore::new();
67
67
let mut scoped_store = LazyScopedVariables::new();
68
-
let mut lazy_graph = Vec::new();
68
+
let mut lazy_graph = LazyGraph::new();
69
69
let mut function_parameters = Vec::new();
70
70
let mut prev_element_debug_info = HashMap::new();
71
71
···
99
99
prev_element_debug_info: &mut prev_element_debug_info,
100
100
cancellation_flag,
101
101
};
102
-
for graph_stmt in &lazy_graph {
103
-
graph_stmt.evaluate(&mut exec)?;
104
-
}
102
+
lazy_graph.evaluate(&mut exec)?;
105
103
// make sure any unforced values are now forced, to surface any problems
106
104
// hidden by the fact that the values were unused
107
105
store.evaluate_all(&mut exec)?;
···
140
138
mat: &'a QueryMatch<'a, 'tree>,
141
139
store: &'a mut LazyStore,
142
140
scoped_store: &'a mut LazyScopedVariables,
143
-
lazy_graph: &'a mut Vec<LazyStatement>,
141
+
lazy_graph: &'a mut LazyGraph,
144
142
function_parameters: &'a mut Vec<graph::Value>, // re-usable buffer to reduce memory allocations
145
143
prev_element_debug_info: &'a mut HashMap<GraphElementKey, DebugInfo>,
146
144
error_context: StatementContext,
···
179
177
locals: &mut VariableMap<'l, LazyValue>,
180
178
store: &mut LazyStore,
181
179
scoped_store: &mut LazyScopedVariables,
182
-
lazy_graph: &mut Vec<LazyStatement>,
180
+
lazy_graph: &mut LazyGraph,
183
181
function_parameters: &mut Vec<graph::Value>,
184
182
prev_element_debug_info: &mut HashMap<GraphElementKey, DebugInfo>,
185
183
inherited_variables: &HashSet<Identifier>,
+40
src/execution/lazy/statements.rs
+40
src/execution/lazy/statements.rs
···
22
22
use super::EvaluationContext;
23
23
use super::GraphElementKey;
24
24
25
+
/// Lazy graph
26
+
#[derive(Debug)]
27
+
pub(super) struct LazyGraph {
28
+
edge_statements: Vec<LazyStatement>,
29
+
attr_statements: Vec<LazyStatement>,
30
+
print_statements: Vec<LazyStatement>,
31
+
}
32
+
33
+
impl LazyGraph {
34
+
pub(super) fn new() -> Self {
35
+
LazyGraph {
36
+
edge_statements: Vec::new(),
37
+
attr_statements: Vec::new(),
38
+
print_statements: Vec::new(),
39
+
}
40
+
}
41
+
42
+
pub(super) fn push(&mut self, stmt: LazyStatement) {
43
+
match stmt {
44
+
LazyStatement::AddGraphNodeAttribute(_) => self.attr_statements.push(stmt),
45
+
LazyStatement::CreateEdge(_) => self.edge_statements.push(stmt),
46
+
LazyStatement::AddEdgeAttribute(_) => self.attr_statements.push(stmt),
47
+
LazyStatement::Print(_) => self.print_statements.push(stmt),
48
+
}
49
+
}
50
+
51
+
pub(super) fn evaluate(&self, exec: &mut EvaluationContext) -> Result<(), ExecutionError> {
52
+
for stmt in &self.edge_statements {
53
+
stmt.evaluate(exec)?;
54
+
}
55
+
for stmt in &self.attr_statements {
56
+
stmt.evaluate(exec)?;
57
+
}
58
+
for stmt in &self.print_statements {
59
+
stmt.evaluate(exec)?;
60
+
}
61
+
Ok(())
62
+
}
63
+
}
64
+
25
65
/// Lazy graph statements
26
66
#[derive(Debug)]
27
67
pub(super) enum LazyStatement {