Skip to content

Commit 759b414

Browse files
committed
Refactor op_call() to use if constexpr
1 parent 0703bd7 commit 759b414

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/evmone/instructions.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -830,17 +830,20 @@ const instr_info* op_call(const instr_info* instr, execution_state& state) noexc
830830

831831
auto cost = 0;
832832
auto has_value = value != 0;
833+
833834
if (has_value)
834-
{
835-
if (kind == EVMC_CALL && state.msg->flags & EVMC_STATIC)
836-
return state.exit(EVMC_STATIC_MODE_VIOLATION);
837835
cost += 9000;
838-
}
839836

840-
if (kind == EVMC_CALL && (has_value || state.rev < EVMC_SPURIOUS_DRAGON))
837+
if constexpr (kind == EVMC_CALL)
841838
{
842-
if (!state.host.account_exists(dst))
843-
cost += 25000;
839+
if (has_value && state.msg->flags & EVMC_STATIC)
840+
return state.exit(EVMC_STATIC_MODE_VIOLATION);
841+
842+
if (has_value || state.rev < EVMC_SPURIOUS_DRAGON)
843+
{
844+
if (!state.host.account_exists(dst))
845+
cost += 25000;
846+
}
844847
}
845848

846849
if ((gas_left -= cost) < 0)

0 commit comments

Comments
 (0)