From 43094c8c52319aa82b03e73700ca1b5f65da13c6 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 13 Aug 2019 22:24:04 +0200 Subject: The syntax has very little sharing; no need for Rc anymore --- dhall_syntax/src/core/expr.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/dhall_syntax/src/core/expr.rs b/dhall_syntax/src/core/expr.rs index 4c809f8..e3f8cec 100644 --- a/dhall_syntax/src/core/expr.rs +++ b/dhall_syntax/src/core/expr.rs @@ -168,8 +168,8 @@ pub enum Builtin { } // Each node carries an annotation. In practice it's either X (no annotation) or a Span. -#[derive(Debug)] -pub struct SubExpr(Rc<(Expr, Option)>); +#[derive(Debug, Clone)] +pub struct SubExpr(Box<(Expr, Option)>); impl std::cmp::PartialEq for SubExpr { fn eq(&self, other: &Self) -> bool { @@ -336,11 +336,11 @@ impl SubExpr { } pub fn new(x: Expr, n: Span) -> Self { - SubExpr(Rc::new((x, Some(n)))) + SubExpr(Box::new((x, Some(n)))) } pub fn from_expr_no_span(x: Expr) -> Self { - SubExpr(Rc::new((x, None))) + SubExpr(Box::new((x, None))) } pub fn from_builtin(b: Builtin) -> Self { @@ -348,7 +348,7 @@ impl SubExpr { } pub fn rewrap(&self, x: Expr) -> SubExpr { - SubExpr(Rc::new((x, (self.0).1.clone()))) + SubExpr(Box::new((x, (self.0).1.clone()))) } } @@ -361,12 +361,6 @@ impl SubExpr { } } -impl Clone for SubExpr { - fn clone(&self) -> Self { - SubExpr(Rc::clone(&self.0)) - } -} - // Should probably rename this pub fn rc(x: Expr) -> SubExpr { SubExpr::from_expr_no_span(x) -- cgit v1.2.3