Refactor AST nodes to use Rc
This commit refactors various AST node types to use `Rc` (Reference Counting) instead of `Box`. This change is primarily driven by the need for shared ownership and more efficient handling of potentially recursive or shared data structures within the AST. The main benefits of this change include: - **Reduced cloning:** `Rc` allows multiple parts of the AST to refer to the same node without needing to clone the entire node. This is particularly beneficial for optimization passes where nodes might be visited multiple times. - **Enabling sharing:** It makes it easier to represent scenarios where a single AST node might be a child of multiple parent nodes. - **Performance improvements:** By avoiding unnecessary deep copies of AST nodes, this change can lead to performance gains, especially during complex compilation phases.
This commit is contained in:
+1
-1
@@ -893,7 +893,7 @@ impl VM {
|
||||
fn eval_and_flatten_internal<O: VMObserver>(
|
||||
&mut self,
|
||||
obs: &mut O,
|
||||
elements: &[ExecNode],
|
||||
elements: &[Rc<ExecNode>],
|
||||
into: &mut Vec<Value>,
|
||||
) -> Result<(), String> {
|
||||
for e in elements {
|
||||
|
||||
Reference in New Issue
Block a user