Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ Checks: "-*,
modernize-deprecated-headers,
modernize-make-shared,
modernize-make-unique,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-vector-operation,
performance-move-const-arg,
performance-move-constructor-init,
performance-no-automatic-move,
performance-trivially-destructible,
readability-avoid-nested-conditional-operator,
readability-avoid-return-with-void-value,
Expand Down Expand Up @@ -149,11 +154,6 @@ Checks: "-*,
# modernize-use-std-numbers,
# modernize-use-using,
#
# performance-faster-string-find,
# performance-for-range-copy,
# performance-inefficient-vector-operation,
# performance-move-const-arg,
# performance-no-automatic-move,
# ---
#
CheckOptions:
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/basics/FileUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ getFileContents(
return {};
}

std::string const result{
std::string result{
std::istreambuf_iterator<char>{fileStream}, std::istreambuf_iterator<char>{}};

if (fileStream.bad())
Expand Down
5 changes: 2 additions & 3 deletions src/libxrpl/ledger/Ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ class Ledger::txs_iter_impl : public txs_type::iter_base

txs_iter_impl(txs_iter_impl const&) = default;

txs_iter_impl(bool metadata, SHAMap::const_iterator iter)
: metadata_(metadata), iter_(std::move(iter))
txs_iter_impl(bool metadata, SHAMap::const_iterator iter) : metadata_(metadata), iter_(iter)
{
}

Expand Down Expand Up @@ -694,7 +693,7 @@ Ledger::updateNegativeUNL()
if (sle->isFieldPresent(sfDisabledValidators))
{
auto const& oldNUnl = sle->getFieldArray(sfDisabledValidators);
for (auto v : oldNUnl)
for (auto const& v : oldNUnl)
{
if (hasToReEnable && v.isFieldPresent(sfPublicKey) &&
v.getFieldVL(sfPublicKey) == sle->getFieldVL(sfValidatorToReEnable))
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/ledger/helpers/TokenHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ getLineIfUsable(
FreezeHandling zeroIfFrozen,
beast::Journal j)
{
auto const sle = view.read(keylet::line(account, issuer, currency));
auto sle = view.read(keylet::line(account, issuer, currency));

if (!sle)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/protocol/BuildInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ encodeSoftwareVersion(std::string_view versionStr)
{
std::uint8_t x = 0;

for (auto id : v.preReleaseIdentifiers)
for (auto const& id : v.preReleaseIdentifiers)
{
auto parsePreRelease = [](std::string_view identifier,
std::string_view prefix,
Expand Down
4 changes: 2 additions & 2 deletions src/libxrpl/protocol/STPathSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ STPath::getJson(JsonOptions) const
{
Json::Value ret(Json::arrayValue);

for (auto it : mPath)
for (auto const& it : mPath)
{
Json::Value elem(Json::objectValue);
auto const iType = it.getNodeType();
Expand All @@ -179,7 +179,7 @@ Json::Value
STPathSet::getJson(JsonOptions options) const
{
Json::Value ret(Json::arrayValue);
for (auto it : value)
for (auto const& it : value)
ret.append(it.getJson(options));

return ret;
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/shamap/SHAMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t)
// The semantics of this changes when we move to c++-20
// Right now no move will occur; With c++-20 child will
// be moved from.
Comment on lines 1024 to 1026
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment about move semantics changing "when we move to c++-20" is now misleading: the code no longer uses std::move(child) here, so the described behavior doesn’t apply. Please update or remove the comment so it matches the current code and C++20 build settings.

Suggested change
// The semantics of this changes when we move to c++-20
// Right now no move will occur; With c++-20 child will
// be moved from.

Copilot uses AI. Check for mistakes.
node = intr_ptr::static_pointer_cast<SHAMapInnerNode>(std::move(child));
node = intr_ptr::static_pointer_cast<SHAMapInnerNode>(child);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not related, but what is the comment here about if all the nodes are operated by pointers?

pos = 0;
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/tx/invariants/PermissionedDomainInvariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ValidPermissionedDomain::visitEntry(
break;
}
}
sleStatus.emplace_back(std::move(ss));
sleStatus.emplace_back(ss);
};

if (after)
Expand Down
4 changes: 2 additions & 2 deletions src/libxrpl/tx/invariants/VaultInvariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ ValidVault::finalize(
for (auto const& e : beforeMPTs_)
{
if (e.share.getMptID() == beforeVault.shareMPTID)
return std::move(e);
return e;
}
return std::nullopt;
}();
Expand Down Expand Up @@ -374,7 +374,7 @@ ValidVault::finalize(
for (auto const& e : beforeMPTs_)
{
if (e.share.getMptID() == beforeVault.shareMPTID)
return std::move(e);
return e;
}
return std::nullopt;
}();
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/tx/transactors/bridge/XChainBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ transferHelper(
auto const reserve = psb.fees().accountReserve(ownerCount);

auto const availableBalance = [&]() -> STAmount {
STAmount const curBal = (*sleSrc)[sfBalance];
STAmount curBal = (*sleSrc)[sfBalance];
// Checking that account == src and postFeeBalance == curBal is
// not strictly necessary, but helps protect against future
// changes
Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/tx/transactors/nft/NFTokenAcceptOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ NFTokenAcceptOffer::transferNFToken(
if (!tokenAndPage)
return tecINTERNAL; // LCOV_EXCL_LINE

if (auto const ret = nft::removeToken(view(), seller, nftokenID, std::move(tokenAndPage->page));
if (auto const ret = nft::removeToken(view(), seller, nftokenID, tokenAndPage->page);
!isTesSuccess(ret))
return ret;

Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/tx/transactors/nft/NFTokenUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ removeToken(ApplyView& view, AccountID const& owner, uint256 const& nftokenID)
if (!page)
return tecNO_ENTRY;

return removeToken(view, owner, nftokenID, std::move(page));
return removeToken(view, owner, nftokenID, page);
}

/** Remove the token from the owner's token directory. */
Expand Down
4 changes: 2 additions & 2 deletions src/libxrpl/tx/transactors/oracle/OracleSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ OracleSet::doApply()
}
STArray updatedSeries;
for (auto const& iter : pairs)
updatedSeries.push_back(std::move(iter.second));
updatedSeries.push_back(iter.second);
sle->setFieldArray(sfPriceDataSeries, updatedSeries);
if (ctx_.tx.isFieldPresent(sfURI))
sle->setFieldVL(sfURI, ctx_.tx[sfURI]);
Expand Down Expand Up @@ -284,7 +284,7 @@ OracleSet::doApply()
pairs.emplace(key, std::move(priceData));
}
for (auto const& iter : pairs)
series.push_back(std::move(iter.second));
series.push_back(iter.second);
}

sle->setFieldArray(sfPriceDataSeries, series);
Expand Down
1 change: 1 addition & 0 deletions src/test/app/Batch_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Batch_test : public beast::unit_test::suite

auto const ids = batchTxn.stx->getBatchTransactionIDs();
std::vector<std::string> txIDs;
txIDs.reserve(ids.size());
for (auto const& id : ids)
txIDs.push_back(strHex(id));
TxID const batchID = batchTxn.stx->getTransactionID();
Expand Down
4 changes: 2 additions & 2 deletions src/test/app/Invariants_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ class Invariants_test : public beast::unit_test::suite
STArray nfTokens = makeNFTokenIDs(1);
auto nftPage = std::make_shared<SLE>(keylet::nftpage(
keylet::nftpage_max(A1), ++(nfTokens[0].getFieldH256(sfNFTokenID))));
nftPage->setFieldArray(sfNFTokens, std::move(nfTokens));
nftPage->setFieldArray(sfNFTokens, nfTokens);
nftPage->setFieldH256(sfNextPageMin, keylet::nftpage_max(A2).key);

ac.view().insert(nftPage);
Expand All @@ -1206,7 +1206,7 @@ class Invariants_test : public beast::unit_test::suite
STArray nfTokens = makeNFTokenIDs(2);
auto nftPage = std::make_shared<SLE>(keylet::nftpage(
keylet::nftpage_max(A1), (nfTokens[1].getFieldH256(sfNFTokenID))));
nftPage->setFieldArray(sfNFTokens, std::move(nfTokens));
nftPage->setFieldArray(sfNFTokens, nfTokens);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We remove std::move() here and in the other places because the object is trivially copyable, right?


ac.view().insert(nftPage);
return true;
Expand Down
1 change: 1 addition & 0 deletions src/test/app/LedgerReplay_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ struct LedgerReplayer_test : public beast::unit_test::suite

auto makeSkipList = [](int count) -> std::vector<uint256> {
std::vector<uint256> sList;
sList.reserve(count);
for (int i = 0; i < count; ++i)
sList.emplace_back(i);
return sList;
Expand Down
10 changes: 6 additions & 4 deletions src/test/app/Loan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ class Loan_test : public beast::unit_test::suite
auto const pseudoAcct = [&]() {
auto const brokerSle = env.le(keylet::loanbroker(broker.brokerID));
if (!BEAST_EXPECT(brokerSle))
return lender;
return Account{lender};
auto const brokerPseudo = brokerSle->at(sfAccount);
return Account("Broker pseudo-account", brokerPseudo);
}();
Expand Down Expand Up @@ -1809,9 +1809,9 @@ class Loan_test : public beast::unit_test::suite
if (!BEAST_EXPECT(vaultSle))
{
// This will be wrong, but the test has failed anyway.
return lender;
return Account{lender};
}
auto const vaultPseudo = Account("Vault pseudo-account", vaultSle->at(sfAccount));
auto vaultPseudo = Account("Vault pseudo-account", vaultSle->at(sfAccount));
return vaultPseudo;
}();

Expand Down Expand Up @@ -2875,6 +2875,7 @@ class Loan_test : public beast::unit_test::suite
// Create vaults and loan brokers
std::array const assets{mptAsset, iouAsset};
std::vector<BrokerInfo> brokers;
brokers.reserve(assets.size());
for (auto const& asset : assets)
{
brokers.emplace_back(createVaultAndBroker(env, asset, lender));
Expand Down Expand Up @@ -3408,6 +3409,7 @@ class Loan_test : public beast::unit_test::suite

// Create vaults and loan brokers
std::vector<BrokerInfo> brokers;
brokers.reserve(assets.size());
for (auto const& asset : assets)
{
brokers.emplace_back(createVaultAndBroker(
Expand Down Expand Up @@ -4566,7 +4568,7 @@ class Loan_test : public beast::unit_test::suite
auto const pseudoAcct = [&]() {
auto const brokerSle = env.le(keylet::loanbroker(broker.brokerID));
if (!BEAST_EXPECT(brokerSle))
return lender;
return Account{lender};
auto const brokerPseudo = brokerSle->at(sfAccount);
return Account("Broker pseudo-account", brokerPseudo);
}();
Expand Down
11 changes: 5 additions & 6 deletions src/test/app/Manifest_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,8 @@ class Manifest_test : public beast::unit_test::suite
Serializer s;
st.add(s);

// 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)))
std::string const m(static_cast<char const*>(s.data()), s.size());
if (auto r = deserializeManifest(m))
return std::move(*r);
Throw<std::runtime_error>("Could not create a revocation manifest");
return *deserializeManifest(std::string{}); // Silence compiler warning.
Expand Down Expand Up @@ -182,9 +181,8 @@ class Manifest_test : public beast::unit_test::suite
Serializer s;
st.add(s);

std::string m(static_cast<char const*>(s.data()),
s.size()); // non-const so can be moved
if (auto r = deserializeManifest(std::move(m)))
std::string const m(static_cast<char const*>(s.data()), s.size());
if (auto r = deserializeManifest(m))
return std::move(*r);
Throw<std::runtime_error>("Could not create a manifest");
return *deserializeManifest(std::string{}); // Silence compiler warning.
Expand Down Expand Up @@ -252,6 +250,7 @@ class Manifest_test : public beast::unit_test::suite
// save should store all trusted master keys to db
std::vector<std::string> s1;
std::vector<std::string> keys;
s1.reserve(inManifests.size());
for (auto const& man : inManifests)
s1.push_back(toBase58(TokenType::NodePublic, man->masterKey));
unl->load({}, s1, keys);
Expand Down
6 changes: 3 additions & 3 deletions src/test/app/Offer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ class OfferBaseUtil_test : public beast::unit_test::suite

auto const aliceOffers = offersOnAccount(env, alice);
BEAST_EXPECT(aliceOffers.size() == 1);
for (auto offerPtr : aliceOffers)
for (auto const& offerPtr : aliceOffers)
{
auto const& offer = *offerPtr;
BEAST_EXPECT(offer[sfTakerGets] == XRP(2000));
Expand All @@ -878,7 +878,7 @@ class OfferBaseUtil_test : public beast::unit_test::suite

auto const bobOffers = offersOnAccount(env, bob);
BEAST_EXPECT(bobOffers.size() == 1);
for (auto offerPtr : bobOffers)
for (auto const& offerPtr : bobOffers)
{
auto const& offer = *offerPtr;
BEAST_EXPECT(offer[sfTakerGets] == USD(1000));
Expand Down Expand Up @@ -927,7 +927,7 @@ class OfferBaseUtil_test : public beast::unit_test::suite

auto const bobOffers = offersOnAccount(env, "bob");
BEAST_EXPECT(bobOffers.size() == 1);
for (auto offerPtr : bobOffers)
for (auto const& offerPtr : bobOffers)
{
auto const& offer = *offerPtr;
BEAST_EXPECT(offer[sfTakerGets] == USD(499.5));
Expand Down
2 changes: 1 addition & 1 deletion src/test/app/RCLValidations_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class RCLValidations_test : public beast::unit_test::suite
{
RCLValidatedLedger a{RCLValidatedLedger::MakeGenesis{}};

for (auto ledger : {history.back(), history[maxAncestors - 1]})
for (auto const& ledger : {history.back(), history[maxAncestors - 1]})
{
RCLValidatedLedger b{ledger, env.journal};
BEAST_EXPECT(mismatch(a, b) == 1);
Expand Down
10 changes: 6 additions & 4 deletions src/test/app/Transaction_ordering_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,28 @@ struct Transaction_ordering_test : public beast::unit_test::suite
env.fund(XRP(1000), noripple(alice));

auto const aliceSequence = env.seq(alice);
static constexpr auto kSIZE = 5;

std::vector<JTx> tx;
for (auto i = 0; i < 5; ++i)
tx.reserve(kSIZE);
for (auto i = 0; i < kSIZE; ++i)
{
tx.emplace_back(env.jt(noop(alice), seq(aliceSequence + i), last_ledger_seq(7)));
}

for (auto i = 1; i < 5; ++i)
for (auto i = 1; i < kSIZE; ++i)
{
env(tx[i], ter(terPRE_SEQ));
BEAST_EXPECT(env.seq(alice) == aliceSequence);
}

env(tx[0]);
env.app().getJobQueue().rendezvous();
BEAST_EXPECT(env.seq(alice) == aliceSequence + 5);
BEAST_EXPECT(env.seq(alice) == aliceSequence + kSIZE);

env.close();

for (auto i = 0; i < 5; ++i)
for (auto i = 0; i < kSIZE; ++i)
{
auto const result = env.rpc("tx", to_string(tx[i].stx->getTransactionID()));
BEAST_EXPECT(result["result"]["meta"]["TransactionResult"] == "tesSUCCESS");
Expand Down
2 changes: 2 additions & 0 deletions src/test/app/ValidatorList_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ class ValidatorList_test : public beast::unit_test::suite

// load should accept valid validator list publisher keys
std::vector<std::string> cfgPublishers;
cfgPublishers.reserve(keys.size());
for (auto const& key : keys)
cfgPublishers.push_back(strHex(key));

Expand All @@ -393,6 +394,7 @@ class ValidatorList_test : public beast::unit_test::suite
std::vector<PublicKey> keys(
{randomMasterKey(), randomMasterKey(), randomMasterKey(), randomMasterKey()});
std::vector<std::string> cfgPublishers;
cfgPublishers.reserve(keys.size());
for (auto const& key : keys)
cfgPublishers.push_back(strHex(key));

Expand Down
1 change: 1 addition & 0 deletions src/test/app/ValidatorSite_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class ValidatorSite_test : public beast::unit_test::suite
auto sites = std::make_unique<ValidatorSite>(env.app(), journal);

std::vector<std::string> uris;
uris.reserve(servers.size());
for (auto const& u : servers)
uris.push_back(u.uri);
sites->load(uris);
Expand Down
2 changes: 1 addition & 1 deletion src/test/app/Vault_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ class Vault_test : public beast::unit_test::suite
return defXRP;
return a + XRP(1000);
}
auto const defIOU = STAmount{a.issue(), 30000};
auto defIOU = STAmount{a.issue(), 30000};
if (a <= defIOU)
return defIOU;
return a + STAmount{a.issue(), 1000};
Expand Down
Loading
Loading