Skip to content

Commit

Permalink
perf: Avoid allocating a new Arc for each type hole during parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Apr 16, 2018
1 parent e36bc7f commit 8ecdccf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions parser/src/grammar.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ AtomicPattern: Pattern<Id> = {
match elems.len() {
// Parenthesized pattern
1 => elems.into_iter().next().unwrap().value,
_ => Pattern::Tuple { typ: Type::hole(), elems: elems },
_ => Pattern::Tuple { typ: type_cache.hole(), elems: elems },
},

"{" <fields: Comma<FieldPattern>> <implicit_import: Sp<"?"?>> "}" => {
Expand All @@ -347,7 +347,7 @@ AtomicPattern: Pattern<Id> = {
let implicit_import_span = implicit_import.span;

Pattern::Record {
typ: Type::hole(),
typ: type_cache.hole(),
types: types,
fields: values,
implicit_import: implicit_import
Expand Down Expand Up @@ -477,18 +477,18 @@ AtomicExpr: Expr<Id> = {
// Expr::Getter(id),

<expr: SpAtomicExpr> "." <id: Ident> =>
Expr::Projection(Box::new(expr), id, Type::hole()),
Expr::Projection(Box::new(expr), id, type_cache.hole()),

<expr: SpAtomicExpr> "." <err: !> => {
errors.push(err.error);
Expr::Projection(Box::new(expr), env.from_str(""), Type::hole())
Expr::Projection(Box::new(expr), env.from_str(""), type_cache.hole())
},

"(" <elems: Comma<SpExpr>> ")" =>
Expr::Tuple { typ: Type::hole(), elems: elems },
Expr::Tuple { typ: type_cache.hole(), elems: elems },

"[" <elems: Comma<SpExpr>> "]" => Expr::Array(Array {
typ: Type::hole(),
typ: type_cache.hole(),
exprs: elems,
}),

Expand All @@ -512,7 +512,7 @@ AtomicExpr: Expr<Id> = {
}

Expr::Record {
typ: Type::hole(),
typ: type_cache.hole(),
types: types,
exprs: values,
base: base.map(Box::new),
Expand Down

0 comments on commit 8ecdccf

Please sign in to comment.