Browse Source

Remove pessimising moves.

cl-refactor
Paweł Bylica 10 years ago
parent
commit
4205cf79f9
  1. 4
      libdevcrypto/Common.cpp
  2. 2
      libdevcrypto/CryptoPP.cpp
  3. 2
      libdevcrypto/CryptoPP.h
  4. 4
      libdevcrypto/OverlayDB.cpp
  5. 2
      libevmasm/Assembly.cpp
  6. 4
      libp2p/Common.h
  7. 4
      libp2p/Host.cpp
  8. 2
      libp2p/Network.cpp
  9. 10
      libp2p/NodeTable.cpp
  10. 4
      libp2p/RLPxFrameIO.cpp
  11. 4
      libp2p/UDP.cpp
  12. 2
      libp2p/UDP.h
  13. 2
      libsolidity/CompilerContext.cpp
  14. 12
      libsolidity/Types.cpp
  15. 2
      test/libp2p/net.cpp
  16. 4
      test/libwhisper/whisperMessage.cpp

4
libdevcrypto/Common.cpp

@ -54,7 +54,7 @@ Public dev::toPublic(Secret const& _secret)
{ {
Public p; Public p;
s_secp256k1.toPublic(_secret, p); s_secp256k1.toPublic(_secret, p);
return std::move(p); return p;
} }
Address dev::toAddress(Public const& _public) Address dev::toAddress(Public const& _public)
@ -230,7 +230,7 @@ h256 crypto::kdf(Secret const& _priv, h256 const& _hash)
if (!s || !_hash || !_priv) if (!s || !_hash || !_priv)
BOOST_THROW_EXCEPTION(InvalidState()); BOOST_THROW_EXCEPTION(InvalidState());
return std::move(s); return s;
} }
h256 Nonce::get(bool _commit) 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); k.resize(kdByteLen);
return move(k); return k;
} }
void Secp256k1::encryptECIES(Public const& _k, bytes& io_cipher) void Secp256k1::encryptECIES(Public const& _k, bytes& io_cipher)

2
libdevcrypto/CryptoPP.h

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

2
libevmasm/Assembly.cpp

@ -109,7 +109,7 @@ string Assembly::getLocationFromSources(StringMap const& _sourceCodes, SourceLoc
if (newLinePos != string::npos) if (newLinePos != string::npos)
cut = cut.substr(0, newLinePos) + "..."; cut = cut.substr(0, newLinePos) + "...";
return move(cut); return cut;
} }
ostream& Assembly::streamAsm(ostream& _out, string const& _prefix, StringMap const& _sourceCodes) const 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 udpPort = 0;
uint16_t tcpPort = 0; uint16_t tcpPort = 0;
operator bi::udp::endpoint() const { return std::move(bi::udp::endpoint(address, udpPort)); } operator bi::udp::endpoint() const { return bi::udp::endpoint(address, udpPort); }
operator bi::tcp::endpoint() const { return std::move(bi::tcp::endpoint(address, tcpPort)); } operator bi::tcp::endpoint() const { return bi::tcp::endpoint(address, tcpPort); }
operator bool() const { return !address.is_unspecified() && udpPort > 0 && tcpPort > 0; } 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); RLP r(_b);
if (r.itemCount() == 3 && r[0].isInt() && r[0].toInt<unsigned>() >= 3) 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 else
return move(KeyPair::create()); return KeyPair::create();
} }

2
libp2p/Network.cpp

@ -111,7 +111,7 @@ std::set<bi::address> Network::getInterfaceAddresses()
#endif #endif
return std::move(addresses); return addresses;
} }
int Network::tcp4Listen(bi::tcp::acceptor& _acceptor, NetworkPreferences const& _netPrefs) 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) if (!_node.endpoint)
return move(shared_ptr<NodeEntry>()); return shared_ptr<NodeEntry>();
// ping address to recover nodeid if nodeid is empty // ping address to recover nodeid if nodeid is empty
if (!_node.id) if (!_node.id)
@ -98,7 +98,7 @@ shared_ptr<NodeEntry> NodeTable::addNode(Node const& _node, NodeRelation _relati
DEV_GUARDED(x_pubkDiscoverPings) DEV_GUARDED(x_pubkDiscoverPings)
m_pubkDiscoverPings[_node.endpoint.address] = std::chrono::steady_clock::now(); m_pubkDiscoverPings[_node.endpoint.address] = std::chrono::steady_clock::now();
ping(_node.endpoint); ping(_node.endpoint);
return move(shared_ptr<NodeEntry>()); return shared_ptr<NodeEntry>();
} }
DEV_GUARDED(x_nodes) DEV_GUARDED(x_nodes)
@ -129,7 +129,7 @@ list<NodeId> NodeTable::nodes() const
DEV_GUARDED(x_nodes) DEV_GUARDED(x_nodes)
for (auto& i: m_nodes) for (auto& i: m_nodes)
nodes.push_back(i.second->id); nodes.push_back(i.second->id);
return move(nodes); return nodes;
} }
list<NodeEntry> NodeTable::snapshot() const list<NodeEntry> NodeTable::snapshot() const
@ -140,7 +140,7 @@ list<NodeEntry> NodeTable::snapshot() const
for (auto const& np: s.nodes) for (auto const& np: s.nodes)
if (auto n = np.lock()) if (auto n = np.lock())
ret.push_back(*n); ret.push_back(*n);
return move(ret); return ret;
} }
Node NodeTable::node(NodeId const& _id) Node NodeTable::node(NodeId const& _id)
@ -282,7 +282,7 @@ vector<shared_ptr<NodeEntry>> NodeTable::nearestNodeEntries(NodeId _target)
for (auto const& n: nodes.second) for (auto const& n: nodes.second)
if (ret.size() < s_bucketSize && !!n->endpoint && n->endpoint.isAllowed()) if (ret.size() < s_bucketSize && !!n->endpoint && n->endpoint.isAllowed())
ret.push_back(n); ret.push_back(n);
return move(ret); return ret;
} }
void NodeTable::ping(NodeIPEndpoint _to) const void NodeTable::ping(NodeIPEndpoint _to) const

4
libp2p/RLPxFrameIO.cpp

@ -154,7 +154,7 @@ h128 RLPXFrameIO::egressDigest()
SHA3_256 h(m_egressMac); SHA3_256 h(m_egressMac);
h128 digest; h128 digest;
h.TruncatedFinal(digest.data(), h128::size); h.TruncatedFinal(digest.data(), h128::size);
return move(digest); return digest;
} }
h128 RLPXFrameIO::ingressDigest() h128 RLPXFrameIO::ingressDigest()
@ -162,7 +162,7 @@ h128 RLPXFrameIO::ingressDigest()
SHA3_256 h(m_ingressMac); SHA3_256 h(m_ingressMac);
h128 digest; h128 digest;
h.TruncatedFinal(digest.data(), h128::size); h.TruncatedFinal(digest.data(), h128::size);
return move(digest); return digest;
} }
void RLPXFrameIO::updateEgressMACWithHeader(bytesConstRef _headerCipher) 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); bytesConstRef signedRLPx(&data[h256::size], data.size() - h256::size);
dev::sha3(signedRLPx).ref().copyTo(rlpxHash); dev::sha3(signedRLPx).ref().copyTo(rlpxHash);
return std::move(sighash); return sighash;
} }
Public RLPXDatagramFace::authenticate(bytesConstRef _sig, bytesConstRef _rlp) Public RLPXDatagramFace::authenticate(bytesConstRef _sig, bytesConstRef _rlp)
{ {
Signature const& sig = *(Signature const*)_sig.data(); 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 struct RLPXDatagram: public RLPXDatagramFace
{ {
RLPXDatagram(bi::udp::endpoint const& _ep): RLPXDatagramFace(_ep) {} 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; } uint8_t packetType() { return T::type; }
}; };

2
libsolidity/CompilerContext.cpp

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

12
libsolidity/Types.cpp

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

2
test/libp2p/net.cpp

@ -74,7 +74,7 @@ struct TestNodeTable: public NodeTable
ret.push_back(make_pair(k,s_basePort+i)); 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) 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); ret.push_back(t);
} }
return move(ret); return ret;
} }
bytes createRandomPayload(unsigned int i) bytes createRandomPayload(unsigned int i)
@ -48,7 +48,7 @@ bytes createRandomPayload(unsigned int i)
for (int j = 0; j < sz; ++j) for (int j = 0; j < sz; ++j)
ret.push_back(rand() % 256); ret.push_back(rand() % 256);
return move(ret); return ret;
} }
void comparePayloads(Message const& m1, Message const& m2) void comparePayloads(Message const& m1, Message const& m2)

Loading…
Cancel
Save