diff options
author | chriseth <chris@ethereum.org> | 2018-07-02 19:00:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-02 19:00:59 +0800 |
commit | 8a4980c05ef7d3408dfb138b17b1610ef648d441 (patch) | |
tree | a6bcc33913d19d54ba3ed6006a58f1684b3b24c4 | |
parent | 85b9d3927a46748583a78e84c87559933954aebc (diff) | |
parent | 0e5b97446a6c4b3af3e330728eea278acf019ea7 (diff) | |
download | dexon-solidity-8a4980c05ef7d3408dfb138b17b1610ef648d441.tar.gz dexon-solidity-8a4980c05ef7d3408dfb138b17b1610ef648d441.tar.zst dexon-solidity-8a4980c05ef7d3408dfb138b17b1610ef648d441.zip |
Merge pull request #4398 from rnaby/libevmasm/KnownState-125
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 |