Skip to content

Commit

Permalink
Simplify prepareSpec(). (#116)
Browse files Browse the repository at this point in the history
`ExprTools.map()` already iterates through blocks and replaces their
contents, so there's no need to type out our own loop.
  • Loading branch information
player-03 authored Nov 8, 2022
1 parent afb943e commit 57b8e56
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/utest/utils/TestBuilder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,10 @@ class TestBuilder {

static function prepareSpec(expr:Expr) {
return switch(expr.expr) {
case EBlock(exprs):
var newExprs = [];
for(expr in exprs) {
switch(expr.expr) {
case EBinop(op, left, right):
newExprs.push(parseSpecBinop(expr, op, left, right));
case EUnop(op, prefix, subj):
newExprs.push(parseSpecUnop(expr, op, prefix, subj));
case _:
newExprs.push(ExprTools.map(expr, prepareSpec));
}
}
{expr:EBlock(newExprs), pos:expr.pos};
case EBinop(op, left, right):
parseSpecBinop(expr, op, left, right);
case EUnop(op, prefix, subj):
parseSpecUnop(expr, op, prefix, subj);
case _:
ExprTools.map(expr, prepareSpec);
}
Expand Down

0 comments on commit 57b8e56

Please sign in to comment.