From 674543d56a562be40afab407956a17c6aa7dc824 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 2 Feb 2014 14:40:32 +0000 Subject: [PATCH] Make patch comply with coding standards. --- TODO | 2 +- libethereum/State.cpp | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index 060afa6f3..084f96c20 100644 --- a/TODO +++ b/TODO @@ -29,7 +29,7 @@ FOR ALPHA: Network: * NotInChain will be very bad for new peers - it'll run through until the genesis. -* UPnP is needed. + - Check how many it has first. UI: * State panel shouldn't show pending (i.e. post-mined) transactions. diff --git a/libethereum/State.cpp b/libethereum/State.cpp index fd3c68f98..c6fa0ee33 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -103,8 +103,8 @@ void State::ensureCached(Address _a, bool _requireMemory, bool _forceCreate) con TrieDB memdb(const_cast(&m_db), it->second.oldRoot()); // promise we won't alter the overlay! :) map& mem = it->second.takeMemory(); for (auto const& i: memdb) - if(mem.find(i.first)==mem.end()) - mem.insert(std::pair(i.first,RLP(i.second).toInt())); + if (mem.find(i.first) == mem.end()) + mem.insert(make_pair(i.first, RLP(i.second).toInt())); else mem.at(i.first) = RLP(i.second).toInt(); } @@ -568,8 +568,8 @@ void State::executeBare(Transaction const& _t, Address _sender) m_cache[newAddress] = AddressState(0, 0, sha3(RLPNull)); auto& mem = m_cache[newAddress].takeMemory(); for (uint i = 0; i < _t.data.size(); ++i) - if(mem.find(i)==mem.end()) - mem.insert(std::pair(i,_t.data[i])); + if (mem.find(i) == mem.end()) + mem.insert(make_pair(i, _t.data[i])); else mem.at(i) = _t.data[i]; @@ -607,14 +607,16 @@ void State::execute(Address _myAddress, Address _txSender, u256 _txValue, u256 _ }; auto setMem = [&](u256 _n, u256 _v) { - if (_v) { - if(myMemory.find(_n)==myMemory.end()) - myMemory.insert(std::pair(_n,_v)); + if (_v) + { + auto it = myMemory.find(_n); + if (it == myMemory.end()) + myMemory.insert(make_pair(_n, _v)); else myMemory.at(_n) = _v; - } else { - myMemory.erase(_n); } + else + myMemory.erase(_n); }; u256 curPC = 0;