Cleanup code using move semantics

This commit is contained in:
seelabs
2020-04-10 14:07:31 -04:00
committed by manojsdoshi
parent 421417ab07
commit 6d28f2a8d9
25 changed files with 132 additions and 116 deletions

View File

@@ -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

View File

@@ -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));

View File

@@ -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;

View File

@@ -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)));