mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Cleanup code using move semantics
This commit is contained in:
@@ -183,11 +183,13 @@ public:
|
||||
Serializer s;
|
||||
st.add(s);
|
||||
|
||||
std::string const m(static_cast<char const*>(s.data()), s.size());
|
||||
// m is non-const so it can be moved from
|
||||
std::string m(static_cast<char const*>(s.data()), s.size());
|
||||
if (auto r = deserializeManifest(std::move(m)))
|
||||
return std::move(*r);
|
||||
Throw<std::runtime_error>("Could not create a revocation manifest");
|
||||
return *deserializeManifest(std::move(m)); // Silence compiler warning.
|
||||
return *deserializeManifest(
|
||||
std::string{}); // Silence compiler warning.
|
||||
}
|
||||
|
||||
Manifest
|
||||
@@ -223,11 +225,14 @@ public:
|
||||
Serializer s;
|
||||
st.add(s);
|
||||
|
||||
std::string const m(static_cast<char const*>(s.data()), s.size());
|
||||
std::string m(
|
||||
static_cast<char const*>(s.data()),
|
||||
s.size()); // non-const so can be moved
|
||||
if (auto r = deserializeManifest(std::move(m)))
|
||||
return std::move(*r);
|
||||
Throw<std::runtime_error>("Could not create a manifest");
|
||||
return *deserializeManifest(std::move(m)); // Silence compiler warning.
|
||||
return *deserializeManifest(
|
||||
std::string{}); // Silence compiler warning.
|
||||
}
|
||||
|
||||
Manifest
|
||||
|
||||
@@ -146,7 +146,7 @@ struct Regression_test : public beast::unit_test::suite
|
||||
auto secp256r1Sig = std::make_unique<STTx>(*(jt.stx));
|
||||
auto pubKeyBlob = strUnHex(secp256r1PubKey);
|
||||
assert(pubKeyBlob); // Hex for public key must be valid
|
||||
secp256r1Sig->setFieldVL(sfSigningPubKey, std::move(*pubKeyBlob));
|
||||
secp256r1Sig->setFieldVL(sfSigningPubKey, *pubKeyBlob);
|
||||
jt.stx.reset(secp256r1Sig.release());
|
||||
|
||||
env(jt, ter(temINVALID));
|
||||
|
||||
@@ -48,7 +48,7 @@ Account::Account(
|
||||
Account
|
||||
Account::fromCache(std::string name, KeyType type)
|
||||
{
|
||||
auto const p = std::make_pair(name, type);
|
||||
auto p = std::make_pair(name, type); // non-const so it can be moved from
|
||||
auto const iter = cache_.find(p);
|
||||
if (iter != cache_.end())
|
||||
return iter->second;
|
||||
|
||||
@@ -151,7 +151,7 @@ class View_test : public beast::unit_test::suite
|
||||
BEAST_EXPECT(seq(v.read(k(3))) == 3);
|
||||
auto s = copy(v.read(k(2)));
|
||||
seq(s, 4);
|
||||
ledger->rawReplace(std::move(s));
|
||||
ledger->rawReplace(s);
|
||||
BEAST_EXPECT(seq(v.read(k(2))) == 4);
|
||||
ledger->rawErase(sle(2));
|
||||
BEAST_EXPECT(!v.exists(k(2)));
|
||||
|
||||
Reference in New Issue
Block a user