From 4e94a3dfc5cade0f8334efa1c785f44eaa55fdac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 19 Sep 2017 07:15:03 +0200 Subject: Eliminate unnecessary and inconsistent casts Consider the types in the code below: BeamInstr* I; . . . BeamInstr* next; next = (BeamInstr *) *I; Goto(next); This is illogical. If 'I' points to a BeamInstr, then 'next' should be a BeamInstr, not a pointer to a BeamInstr. The Goto() macros does not require a pointer, because it will cast its argument to a void* anyway. Therefore, this code example can be simplified to: BeamInstr* I; . . . BeamInstr next; next = *I; Goto(next); Similarly, we can remove the casts in the macros when NO_JUMP_TABLE is defined. --- erts/emulator/utils/beam_makeops | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'erts/emulator/utils/beam_makeops') diff --git a/erts/emulator/utils/beam_makeops b/erts/emulator/utils/beam_makeops index a9b2c8861c..083e7eb523 100755 --- a/erts/emulator/utils/beam_makeops +++ b/erts/emulator/utils/beam_makeops @@ -1438,11 +1438,10 @@ sub code_gen { "ASSERT(VALID_INSTR(*I));\n" . "Goto(*I);"; } else { - $var_decls .= "BeamInstr* _nextpf = " . - "(BeamInstr *) I[$instr_offset];\n"; + $var_decls .= "BeamInstr next_pf = I[$instr_offset];\n"; $dispatch_next = "\nI += $instr_offset;\n" . - "ASSERT(VALID_INSTR(_nextpf));\n" . - "Goto(_nextpf);"; + "ASSERT(VALID_INSTR(next_pf));\n" . + "Goto(next_pf);"; } # -- cgit v1.2.3