Browse Source

Merge pull request #2112 from chfast/refactor_move_override

Pessimising moves and missing overrides
cl-refactor
Gav Wood 10 years ago
parent
commit
ffaea938d9
  1. 2
      alethzero/MainWin.h
  2. 6
      alethzero/NatspecHandler.h
  3. 5
      json_spirit/json_spirit_writer_template.h
  4. 4
      libdevcrypto/Common.cpp
  5. 2
      libdevcrypto/CryptoPP.cpp
  6. 2
      libdevcrypto/CryptoPP.h
  7. 4
      libdevcrypto/OverlayDB.cpp
  8. 4
      libethereum/Client.h
  9. 7
      libethereum/ClientBase.h
  10. 2
      libevmasm/Assembly.cpp
  11. 4
      libp2p/Common.h
  12. 4
      libp2p/Host.cpp
  13. 2
      libp2p/Network.cpp
  14. 10
      libp2p/NodeTable.cpp
  15. 4
      libp2p/RLPxFrameIO.cpp
  16. 4
      libp2p/UDP.cpp
  17. 2
      libp2p/UDP.h
  18. 2
      libsolidity/AST.h
  19. 2
      libsolidity/CompilerContext.cpp
  20. 2
      libsolidity/LValue.h
  21. 12
      libsolidity/Types.cpp
  22. 4
      libsolidity/Types.h
  23. 2
      libtestutils/FixedClient.h
  24. 2
      libweb3jsonrpc/WebThreeStubServer.h
  25. 8
      libwhisper/WhisperHost.h
  26. 2
      mix/CodeModel.cpp
  27. 2
      mix/MixClient.h
  28. 2
      test/libp2p/net.cpp
  29. 4
      test/libwhisper/whisperMessage.cpp

2
alethzero/MainWin.h

@ -238,7 +238,7 @@ private:
void installNameRegWatch();
void installBalancesWatch();
virtual void timerEvent(QTimerEvent*);
virtual void timerEvent(QTimerEvent*) override;
void refreshNetwork();
void refreshMining();

6
alethzero/NatspecHandler.h

@ -39,17 +39,17 @@ class NatspecHandler: public NatSpecFace
~NatspecHandler();
/// Stores locally in a levelDB a key value pair of contract code hash to natspec documentation
void add(dev::h256 const& _contractHash, std::string const& _doc);
virtual void add(dev::h256 const& _contractHash, std::string const& _doc) override;
/// Retrieves the natspec documentation as a string given a contract code hash
std::string retrieve(dev::h256 const& _contractHash) const override;
/// Given a json natspec string and the transaction data return the user notice
std::string getUserNotice(std::string const& json, const dev::bytes& _transactionData);
virtual std::string getUserNotice(std::string const& json, const dev::bytes& _transactionData) override;
/// Given a contract code hash and the transaction's data retrieve the natspec documention's
/// user notice for that transaction.
/// @returns The user notice or an empty string if no natspec for the contract exists
/// or if the existing natspec does not document the @c _methodName
std::string getUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionDacta);
virtual std::string getUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionDacta) override;
private:
ldb::ReadOptions m_readOptions;

5
json_spirit/json_spirit_writer_template.h

@ -25,13 +25,9 @@ namespace json_spirit
return 'A' - 10 + ch;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-local-typedefs")
template< class String_type >
String_type non_printable_to_string( unsigned int c )
{
typedef typename String_type::value_type Char_type;
String_type result( 6, '\\' );
result[1] = 'u';
@ -43,7 +39,6 @@ namespace json_spirit
return result;
}
#pragma GCC diagnostic pop
template< typename Char_type, class String_type >
bool add_esc_char( Char_type c, String_type& s )

4
libdevcrypto/Common.cpp

@ -54,7 +54,7 @@ Public dev::toPublic(Secret const& _secret)
{
Public p;
s_secp256k1.toPublic(_secret, p);
return std::move(p);
return p;
}
Address dev::toAddress(Public const& _public)
@ -230,7 +230,7 @@ h256 crypto::kdf(Secret const& _priv, h256 const& _hash)
if (!s || !_hash || !_priv)
BOOST_THROW_EXCEPTION(InvalidState());
return std::move(s);
return s;
}
h256 Nonce::get(bool _commit)

2
libdevcrypto/CryptoPP.cpp

@ -61,7 +61,7 @@ bytes Secp256k1::eciesKDF(Secret _z, bytes _s1, unsigned kdByteLen)
}
k.resize(kdByteLen);
return move(k);
return k;
}
void Secp256k1::encryptECIES(Public const& _k, bytes& io_cipher)

2
libdevcrypto/CryptoPP.h

@ -59,7 +59,7 @@ namespace crypto
using namespace CryptoPP;
inline ECP::Point publicToPoint(Public const& _p) { Integer x(_p.data(), 32); Integer y(_p.data() + 32, 32); return std::move(ECP::Point(x,y)); }
inline ECP::Point publicToPoint(Public const& _p) { Integer x(_p.data(), 32); Integer y(_p.data() + 32, 32); return ECP::Point(x,y); }
inline Integer secretToExponent(Secret const& _s) { return std::move(Integer(_s.data(), Secret::size)); }

4
libdevcrypto/OverlayDB.cpp

@ -95,7 +95,7 @@ bytes OverlayDB::lookupAux(h256 const& _h) const
{
bytes ret = MemoryDB::lookupAux(_h);
if (!ret.empty() || !m_db)
return move(ret);
return ret;
std::string v;
bytes b = _h.asBytes();
b.push_back(255); // for aux
@ -116,7 +116,7 @@ std::string OverlayDB::lookup(h256 const& _h) const
std::string ret = MemoryDB::lookup(_h);
if (ret.empty() && m_db)
m_db->Get(m_readOptions, ldb::Slice((char const*)_h.data(), 32), &ret);
return move(ret);
return ret;
}
bool OverlayDB::exists(h256 const& _h) const

4
libethereum/Client.h

@ -143,7 +143,7 @@ public:
ExecutionResult call(Address _dest, bytes const& _data = bytes(), u256 _gas = 125000, u256 _value = 0, u256 _gasPrice = 1 * ether, Address const& _from = Address());
/// Get the remaining gas limit in this block.
virtual u256 gasLimitRemaining() const { return m_postMine.gasLimitRemaining(); }
virtual u256 gasLimitRemaining() const override { return m_postMine.gasLimitRemaining(); }
// [PRIVATE API - only relevant for base clients, not available in general]
dev::eth::State state(unsigned _txi, h256 _block) const;
@ -159,7 +159,7 @@ public:
// Mining stuff:
void setAddress(Address _us) { WriteGuard l(x_preMine); m_preMine.setAddress(_us); }
virtual void setAddress(Address _us) override { WriteGuard l(x_preMine); m_preMine.setAddress(_us); }
/// Check block validity prior to mining.
bool miningParanoia() const { return m_paranoia; }

7
libethereum/ClientBase.h

@ -132,8 +132,8 @@ public:
virtual Transactions pending() const override;
virtual h256s pendingHashes() const override;
ImportResult injectTransaction(bytes const& _rlp) override { prepareForTransaction(); return m_tq.import(_rlp); }
ImportResult injectBlock(bytes const& _block);
virtual ImportResult injectTransaction(bytes const& _rlp) override { prepareForTransaction(); return m_tq.import(_rlp); }
virtual ImportResult injectBlock(bytes const& _block) override;
using Interface::diff;
virtual StateDiff diff(unsigned _txi, h256 _block) const override;
@ -143,9 +143,6 @@ public:
virtual Addresses addresses(BlockNumber _block) const override;
virtual u256 gasLimitRemaining() const override;
/// Set the coinbase address
virtual void setAddress(Address _us) = 0;
/// Get the coinbase address
virtual Address address() const override;

2
libevmasm/Assembly.cpp

@ -109,7 +109,7 @@ string Assembly::getLocationFromSources(StringMap const& _sourceCodes, SourceLoc
if (newLinePos != string::npos)
cut = cut.substr(0, newLinePos) + "...";
return move(cut);
return cut;
}
ostream& Assembly::streamAsm(ostream& _out, string const& _prefix, StringMap const& _sourceCodes) const

4
libp2p/Common.h

@ -183,8 +183,8 @@ struct NodeIPEndpoint
uint16_t udpPort = 0;
uint16_t tcpPort = 0;
operator bi::udp::endpoint() const { return std::move(bi::udp::endpoint(address, udpPort)); }
operator bi::tcp::endpoint() const { return std::move(bi::tcp::endpoint(address, tcpPort)); }
operator bi::udp::endpoint() const { return bi::udp::endpoint(address, udpPort); }
operator bi::tcp::endpoint() const { return bi::tcp::endpoint(address, tcpPort); }
operator bool() const { return !address.is_unspecified() && udpPort > 0 && tcpPort > 0; }

4
libp2p/Host.cpp

@ -834,7 +834,7 @@ KeyPair Host::networkAlias(bytesConstRef _b)
{
RLP r(_b);
if (r.itemCount() == 3 && r[0].isInt() && r[0].toInt<unsigned>() >= 3)
return move(KeyPair(move(Secret(r[1].toBytes()))));
return KeyPair(Secret(r[1].toBytes()));
else
return move(KeyPair::create());
return KeyPair::create();
}

2
libp2p/Network.cpp

@ -111,7 +111,7 @@ std::set<bi::address> Network::getInterfaceAddresses()
#endif
return std::move(addresses);
return addresses;
}
int Network::tcp4Listen(bi::tcp::acceptor& _acceptor, NetworkPreferences const& _netPrefs)

10
libp2p/NodeTable.cpp

@ -88,7 +88,7 @@ shared_ptr<NodeEntry> NodeTable::addNode(Node const& _node, NodeRelation _relati
}
if (!_node.endpoint)
return move(shared_ptr<NodeEntry>());
return shared_ptr<NodeEntry>();
// ping address to recover nodeid if nodeid is empty
if (!_node.id)
@ -98,7 +98,7 @@ shared_ptr<NodeEntry> NodeTable::addNode(Node const& _node, NodeRelation _relati
DEV_GUARDED(x_pubkDiscoverPings)
m_pubkDiscoverPings[_node.endpoint.address] = std::chrono::steady_clock::now();
ping(_node.endpoint);
return move(shared_ptr<NodeEntry>());
return shared_ptr<NodeEntry>();
}
DEV_GUARDED(x_nodes)
@ -129,7 +129,7 @@ list<NodeId> NodeTable::nodes() const
DEV_GUARDED(x_nodes)
for (auto& i: m_nodes)
nodes.push_back(i.second->id);
return move(nodes);
return nodes;
}
list<NodeEntry> NodeTable::snapshot() const
@ -140,7 +140,7 @@ list<NodeEntry> NodeTable::snapshot() const
for (auto const& np: s.nodes)
if (auto n = np.lock())
ret.push_back(*n);
return move(ret);
return ret;
}
Node NodeTable::node(NodeId const& _id)
@ -282,7 +282,7 @@ vector<shared_ptr<NodeEntry>> NodeTable::nearestNodeEntries(NodeId _target)
for (auto const& n: nodes.second)
if (ret.size() < s_bucketSize && !!n->endpoint && n->endpoint.isAllowed())
ret.push_back(n);
return move(ret);
return ret;
}
void NodeTable::ping(NodeIPEndpoint _to) const

4
libp2p/RLPxFrameIO.cpp

@ -154,7 +154,7 @@ h128 RLPXFrameIO::egressDigest()
SHA3_256 h(m_egressMac);
h128 digest;
h.TruncatedFinal(digest.data(), h128::size);
return move(digest);
return digest;
}
h128 RLPXFrameIO::ingressDigest()
@ -162,7 +162,7 @@ h128 RLPXFrameIO::ingressDigest()
SHA3_256 h(m_ingressMac);
h128 digest;
h.TruncatedFinal(digest.data(), h128::size);
return move(digest);
return digest;
}
void RLPXFrameIO::updateEgressMACWithHeader(bytesConstRef _headerCipher)

4
libp2p/UDP.cpp

@ -52,12 +52,12 @@ h256 RLPXDatagramFace::sign(Secret const& _k)
bytesConstRef signedRLPx(&data[h256::size], data.size() - h256::size);
dev::sha3(signedRLPx).ref().copyTo(rlpxHash);
return std::move(sighash);
return sighash;
}
Public RLPXDatagramFace::authenticate(bytesConstRef _sig, bytesConstRef _rlp)
{
Signature const& sig = *(Signature const*)_sig.data();
return std::move(dev::recover(sig, sha3(_rlp)));
return dev::recover(sig, sha3(_rlp));
}

2
libp2p/UDP.h

@ -81,7 +81,7 @@ template <class T>
struct RLPXDatagram: public RLPXDatagramFace
{
RLPXDatagram(bi::udp::endpoint const& _ep): RLPXDatagramFace(_ep) {}
static T fromBytesConstRef(bi::udp::endpoint const& _ep, bytesConstRef _bytes) { try { T t(_ep); t.interpretRLP(_bytes); return std::move(t); } catch(...) { T t(_ep); return std::move(t); } }
static T fromBytesConstRef(bi::udp::endpoint const& _ep, bytesConstRef _bytes) { try { T t(_ep); t.interpretRLP(_bytes); return t; } catch(...) { return T{_ep}; } }
uint8_t packetType() { return T::type; }
};

2
libsolidity/AST.h

@ -503,7 +503,7 @@ public:
/// Returns the declared or inferred type. Can be an empty pointer if no type was explicitly
/// declared and there is no assignment to the variable that fixes the type.
TypePointer getType(ContractDefinition const* = nullptr) const { return m_type; }
TypePointer getType(ContractDefinition const* = nullptr) const override { return m_type; }
void setType(std::shared_ptr<Type const> const& _type) { m_type = _type; }
virtual bool isLValue() const override;

2
libsolidity/CompilerContext.cpp

@ -133,7 +133,7 @@ set<Declaration const*> CompilerContext::getFunctionsWithoutCode()
for (auto const& it: m_functionEntryLabels)
if (m_functionsWithCode.count(it.first) == 0)
functions.insert(it.first);
return move(functions);
return functions;
}
ModifierDefinition const& CompilerContext::getFunctionModifier(string const& _name) const

2
libsolidity/LValue.h

@ -109,7 +109,7 @@ public:
StorageItem(CompilerContext& _compilerContext, Declaration const& _declaration);
/// Constructs the LValue and assumes that the storage reference is already on the stack.
StorageItem(CompilerContext& _compilerContext, Type const& _type);
virtual unsigned sizeOnStack() const { return 2; }
virtual unsigned sizeOnStack() const override { return 2; }
virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override;
virtual void storeValue(
Type const& _sourceType,

12
libsolidity/Types.cpp

@ -1459,29 +1459,29 @@ MagicType::MagicType(MagicType::Kind _kind):
switch (m_kind)
{
case Kind::Block:
m_members = move(MemberList({
m_members = MemberList({
{"coinbase", make_shared<IntegerType>(0, IntegerType::Modifier::Address)},
{"timestamp", make_shared<IntegerType>(256)},
{"blockhash", make_shared<FunctionType>(strings{"uint"}, strings{"bytes32"}, FunctionType::Location::BlockHash)},
{"difficulty", make_shared<IntegerType>(256)},
{"number", make_shared<IntegerType>(256)},
{"gaslimit", make_shared<IntegerType>(256)}
}));
});
break;
case Kind::Message:
m_members = move(MemberList({
m_members = MemberList({
{"sender", make_shared<IntegerType>(0, IntegerType::Modifier::Address)},
{"gas", make_shared<IntegerType>(256)},
{"value", make_shared<IntegerType>(256)},
{"data", make_shared<ArrayType>(ReferenceType::Location::CallData)},
{"sig", make_shared<FixedBytesType>(4)}
}));
});
break;
case Kind::Transaction:
m_members = move(MemberList({
m_members = MemberList({
{"origin", make_shared<IntegerType>(0, IntegerType::Modifier::Address)},
{"gasprice", make_shared<IntegerType>(256)}
}));
});
break;
default:
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of magic."));

4
libsolidity/Types.h

@ -407,7 +407,7 @@ public:
virtual TypePointer unaryOperatorResult(Token::Value _operator) const override;
virtual bool operator==(const Type& _other) const override;
virtual unsigned getCalldataEncodedSize(bool _padded) const override;
virtual bool isDynamicallySized() const { return m_hasDynamicLength; }
virtual bool isDynamicallySized() const override { return m_hasDynamicLength; }
virtual u256 getStorageSize() const override;
virtual unsigned getSizeOnStack() const override;
virtual std::string toString() const override;
@ -820,7 +820,7 @@ public:
return TypePointer();
}
virtual bool operator==(Type const& _other) const;
virtual bool operator==(Type const& _other) const override;
virtual bool canBeStored() const override { return false; }
virtual bool canLiveOutsideStorage() const override { return true; }
virtual unsigned getSizeOnStack() const override { return 0; }

2
libtestutils/FixedClient.h

@ -48,7 +48,7 @@ public:
virtual eth::State asOf(h256 const& _h) const override;
virtual eth::State preMine() const override { ReadGuard l(x_stateDB); return m_state; }
virtual eth::State postMine() const override { ReadGuard l(x_stateDB); return m_state; }
virtual void setAddress(Address _us) { WriteGuard l(x_stateDB); m_state.setAddress(_us); }
virtual void setAddress(Address _us) override { WriteGuard l(x_stateDB); m_state.setAddress(_us); }
virtual void prepareForTransaction() override {}
private:

2
libweb3jsonrpc/WebThreeStubServer.h

@ -43,7 +43,7 @@ class WebThreeStubServer: public dev::WebThreeStubServerBase, public dev::WebThr
public:
WebThreeStubServer(jsonrpc::AbstractServerConnector& _conn, dev::WebThreeDirect& _web3, std::shared_ptr<dev::eth::AccountHolder> const& _ethAccounts, std::vector<dev::KeyPair> const& _shhAccounts);
virtual std::string web3_clientVersion();
virtual std::string web3_clientVersion() override;
private:
virtual dev::eth::Interface* client() override;

8
libwhisper/WhisperHost.h

@ -54,7 +54,7 @@ public:
virtual void inject(Envelope const& _e, WhisperPeer* _from = nullptr) override;
virtual Topics const& fullTopics(unsigned _id) const { try { return m_filters.at(m_watches.at(_id).id).full; } catch (...) { return EmptyTopics; } }
virtual Topics const& fullTopics(unsigned _id) const override { try { return m_filters.at(m_watches.at(_id).id).full; } catch (...) { return EmptyTopics; } }
virtual unsigned installWatch(Topics const& _filter) override;
virtual unsigned installWatchOnId(h256 _filterId) override;
virtual void uninstallWatch(unsigned _watchId) override;
@ -69,11 +69,11 @@ public:
void cleanup();
protected:
void doWork();
virtual void doWork() override;
private:
virtual void onStarting() { startWorking(); }
virtual void onStopping() { stopWorking(); }
virtual void onStarting() override { startWorking(); }
virtual void onStopping() override { stopWorking(); }
void streamMessage(h256 _m, RLPStream& _s) const;

2
mix/CodeModel.cpp

@ -67,7 +67,7 @@ private:
return LocationPair(_node.getLocation().start, _node.getLocation().end);
}
virtual bool visit(FunctionDefinition const&)
virtual bool visit(FunctionDefinition const&) override
{
m_functionScope = true;
return true;

2
mix/MixClient.h

@ -80,7 +80,7 @@ protected:
/// ClientBase methods
using ClientBase::asOf;
virtual dev::eth::State asOf(h256 const& _block) const override;
virtual dev::eth::BlockChain& bc() { return *m_bc; }
virtual dev::eth::BlockChain& bc() override { return *m_bc; }
virtual dev::eth::BlockChain const& bc() const override { return *m_bc; }
virtual dev::eth::State preMine() const override { ReadGuard l(x_state); return m_startState; }
virtual dev::eth::State postMine() const override { ReadGuard l(x_state); return m_state; }

2
test/libp2p/net.cpp

@ -74,7 +74,7 @@ struct TestNodeTable: public NodeTable
ret.push_back(make_pair(k,s_basePort+i));
}
return std::move(ret);
return ret;
}
void pingTestNodes(std::vector<std::pair<KeyPair,unsigned>> const& _testNodes)

4
test/libwhisper/whisperMessage.cpp

@ -37,7 +37,7 @@ Topics createRandomTopics(unsigned int i)
ret.push_back(t);
}
return move(ret);
return ret;
}
bytes createRandomPayload(unsigned int i)
@ -48,7 +48,7 @@ bytes createRandomPayload(unsigned int i)
for (int j = 0; j < sz; ++j)
ret.push_back(rand() % 256);
return move(ret);
return ret;
}
void comparePayloads(Message const& m1, Message const& m2)

Loading…
Cancel
Save