From ef120a71941104909f55ae13661368d5646ce0b4 Mon Sep 17 00:00:00 2001 From: Ulf Norell Date: Fri, 3 May 2019 08:49:17 +0200 Subject: [PATCH] Simplify JUMPIF on true/false --- src/aeso_fcode_to_fate.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index d14b49b..572a4e1 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -1137,10 +1137,13 @@ block(Blk = #blk{code = [{switch, Arg, Type, Alts, Default} | Code], _ -> FalseCode ++ [{jump, RestRef}] end, case lists:usort(Alts) == [missing] of - true -> - {Blk#blk{code = [{jump, DefRef}]}, [], []}; + true -> {Blk#blk{code = [{jump, DefRef}]}, [], []}; false -> - {Blk#blk{code = ElseCode}, [{jumpif, Arg, ThenRef}], ThenBlk} + case Arg of + ?i(false) -> {Blk#blk{code = ElseCode}, [], ThenBlk}; + ?i(true) -> {Blk#blk{code = []}, [{jump, ThenRef}], ThenBlk}; + _ -> {Blk#blk{code = ElseCode}, [{jumpif, Arg, ThenRef}], ThenBlk} + end end; tuple -> [TCode] = Alts,