diff options
author | Khan M Rashedun-Naby <naby88@gmail.com> | 2018-07-02 17:42:30 +0800 |
---|---|---|
committer | Khan M Rashedun-Naby <naby88@gmail.com> | 2018-07-02 17:42:30 +0800 |
commit | 0e5b97446a6c4b3af3e330728eea278acf019ea7 (patch) | |
tree | ddc207d376f22e1c55744f0dda7c92d5b7f0afe8 | |
parent | e289c36158701ba0b874051e9e426e270b0e38e2 (diff) | |
download | dexon-solidity-0e5b97446a6c4b3af3e330728eea278acf019ea7.tar dexon-solidity-0e5b97446a6c4b3af3e330728eea278acf019ea7.tar.gz dexon-solidity-0e5b97446a6c4b3af3e330728eea278acf019ea7.tar.bz2 dexon-solidity-0e5b97446a6c4b3af3e330728eea278acf019ea7.tar.lz dexon-solidity-0e5b97446a6c4b3af3e330728eea278acf019ea7.tar.xz dexon-solidity-0e5b97446a6c4b3af3e330728eea278acf019ea7.tar.zst dexon-solidity-0e5b97446a6c4b3af3e330728eea278acf019ea7.zip |
As SWITCH..CASE is better than ELSE..IF
-rw-r--r-- | libevmasm/KnownState.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp index e2f10f22..7c593fc9 100644 --- a/libevmasm/KnownState.cpp +++ b/libevmasm/KnownState.cpp @@ -121,28 +121,33 @@ KnownState::StoreOperation KnownState::feedItem(AssemblyItem const& _item, bool vector<Id> arguments(info.args); for (int i = 0; i < info.args; ++i) arguments[i] = stackElement(m_stackHeight - i, _item.location()); - - if (_item.instruction() == Instruction::SSTORE) + switch (_item.instruction()) + { + case Instruction::SSTORE: op = storeInStorage(arguments[0], arguments[1], _item.location()); - else if (_item.instruction() == Instruction::SLOAD) + break; + case Instruction::SLOAD: setStackElement( m_stackHeight + _item.deposit(), loadFromStorage(arguments[0], _item.location()) ); - else if (_item.instruction() == Instruction::MSTORE) + break; + case Instruction::MSTORE: op = storeInMemory(arguments[0], arguments[1], _item.location()); - else if (_item.instruction() == Instruction::MLOAD) + break; + case Instruction::MLOAD: setStackElement( m_stackHeight + _item.deposit(), loadFromMemory(arguments[0], _item.location()) ); - else if (_item.instruction() == Instruction::KECCAK256) + break; + case Instruction::KECCAK256: setStackElement( m_stackHeight + _item.deposit(), applyKeccak256(arguments.at(0), arguments.at(1), _item.location()) ); - else - { + break; + default: bool invMem = SemanticInformation::invalidatesMemory(_item.instruction()); bool invStor = SemanticInformation::invalidatesStorage(_item.instruction()); // We could be a bit more fine-grained here (CALL only invalidates part of |