Skip to content

Commit d779b80

Browse files
committed
refactor: use empty() instead of comparing against empty string literal
1 parent cd65820 commit d779b80

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/rpc/evo.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ static UniValue protx_register_common_wrapper(const JSONRPCRequest& request,
680680
paramIdx += 2;
681681
}
682682

683-
if (request.params[paramIdx].get_str() != "") {
683+
if (!request.params[paramIdx].get_str().empty()) {
684684
if (auto addr = Lookup(request.params[paramIdx].get_str(), Params().GetDefaultPort(), false); addr.has_value()) {
685685
ptx.addr = addr.value();
686686
} else {
@@ -694,7 +694,7 @@ static UniValue protx_register_common_wrapper(const JSONRPCRequest& request,
694694

695695
CKeyID keyIDVoting = ptx.keyIDOwner;
696696

697-
if (request.params[paramIdx + 3].get_str() != "") {
697+
if (!request.params[paramIdx + 3].get_str().empty()) {
698698
keyIDVoting = ParsePubKeyIDFromAddress(request.params[paramIdx + 3].get_str(), "voting address");
699699
}
700700

@@ -1106,7 +1106,7 @@ static RPCHelpMan protx_update_registrar_wrapper(const bool specific_legacy_bls_
11061106
ptx.keyIDVoting = dmn->pdmnState->keyIDVoting;
11071107
ptx.scriptPayout = dmn->pdmnState->scriptPayout;
11081108

1109-
if (request.params[1].get_str() != "") {
1109+
if (!request.params[1].get_str().empty()) {
11101110
// new pubkey
11111111
ptx.pubKeyOperator.Set(ParseBLSPubKey(request.params[1].get_str(), "operator BLS address", use_legacy), use_legacy);
11121112
} else {
@@ -1116,13 +1116,13 @@ static RPCHelpMan protx_update_registrar_wrapper(const bool specific_legacy_bls_
11161116

11171117
CHECK_NONFATAL(ptx.pubKeyOperator.IsLegacy() == (ptx.nVersion == ProTxVersion::LegacyBLS));
11181118

1119-
if (request.params[2].get_str() != "") {
1119+
if (!request.params[2].get_str().empty()) {
11201120
ptx.keyIDVoting = ParsePubKeyIDFromAddress(request.params[2].get_str(), "voting address");
11211121
}
11221122

11231123
CTxDestination payoutDest;
11241124
ExtractDestination(ptx.scriptPayout, payoutDest);
1125-
if (request.params[3].get_str() != "") {
1125+
if (!request.params[3].get_str().empty()) {
11261126
payoutDest = DecodeDestination(request.params[3].get_str());
11271127
if (!IsValidDestination(payoutDest)) {
11281128
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("invalid payout address: %s", request.params[3].get_str()));

src/rpc/masternode.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static RPCHelpMan masternode_winners()
263263
auto payee = node.dmnman->GetListForBlock(pIndex).GetMNPayee(pIndex);
264264
if (payee) {
265265
std::string strPayments = GetRequiredPaymentsString(*CHECK_NONFATAL(node.govman), tip_mn_list, h, payee);
266-
if (strFilter != "" && strPayments.find(strFilter) == std::string::npos) continue;
266+
if (!strFilter.empty() && strPayments.find(strFilter) == std::string::npos) continue;
267267
obj.pushKV(strprintf("%d", h), strPayments);
268268
}
269269
}
@@ -272,7 +272,7 @@ static RPCHelpMan masternode_winners()
272272
for (size_t i = 0; i < projection.size(); i++) {
273273
int h = nChainTipHeight + 1 + i;
274274
std::string strPayments = GetRequiredPaymentsString(*node.govman, tip_mn_list, h, projection[i]);
275-
if (strFilter != "" && strPayments.find(strFilter) == std::string::npos) continue;
275+
if (!strFilter.empty() && strPayments.find(strFilter) == std::string::npos) continue;
276276
obj.pushKV(strprintf("%d", h), strPayments);
277277
}
278278

@@ -566,7 +566,7 @@ static RPCHelpMan masternodelist_helper(bool is_composite)
566566

567567
if (strMode == "addr") {
568568
std::string strAddress = dmn.pdmnState->addr.ToStringAddrPort();
569-
if (strFilter !="" && strAddress.find(strFilter) == std::string::npos &&
569+
if (!strFilter.empty() && strAddress.find(strFilter) == std::string::npos &&
570570
strOutpoint.find(strFilter) == std::string::npos) return;
571571
obj.pushKV(strOutpoint, strAddress);
572572
} else if (strMode == "full") {
@@ -577,7 +577,7 @@ static RPCHelpMan masternodelist_helper(bool is_composite)
577577
PadString(ToString(dmnToLastPaidTime(dmn)), 10),
578578
PadString(ToString(dmn.pdmnState->nLastPaidHeight), 6),
579579
dmn.pdmnState->addr.ToStringAddrPort());
580-
if (strFilter !="" && strFull.find(strFilter) == std::string::npos &&
580+
if (!strFilter.empty() && strFull.find(strFilter) == std::string::npos &&
581581
strOutpoint.find(strFilter) == std::string::npos) return;
582582
obj.pushKV(strOutpoint, strFull);
583583
} else if (strMode == "info") {
@@ -586,7 +586,7 @@ static RPCHelpMan masternodelist_helper(bool is_composite)
586586
dmn.pdmnState->nPoSePenalty,
587587
payeeStr,
588588
dmn.pdmnState->addr.ToStringAddrPort());
589-
if (strFilter !="" && strInfo.find(strFilter) == std::string::npos &&
589+
if (!strFilter.empty() && strInfo.find(strFilter) == std::string::npos &&
590590
strOutpoint.find(strFilter) == std::string::npos) return;
591591
obj.pushKV(strOutpoint, strInfo);
592592
} else if (strMode == "json" || strMode == "recent" || strMode == "evo") {
@@ -602,7 +602,7 @@ static RPCHelpMan masternodelist_helper(bool is_composite)
602602
EncodeDestination(PKHash(dmn.pdmnState->keyIDVoting)),
603603
collateralAddressStr,
604604
dmn.pdmnState->pubKeyOperator.ToString());
605-
if (strFilter !="" && strInfo.find(strFilter) == std::string::npos &&
605+
if (!strFilter.empty() && strInfo.find(strFilter) == std::string::npos &&
606606
strOutpoint.find(strFilter) == std::string::npos) return;
607607
UniValue objMN(UniValue::VOBJ);
608608
objMN.pushKV("proTxHash", dmn.proTxHash.ToString());
@@ -625,28 +625,28 @@ static RPCHelpMan masternodelist_helper(bool is_composite)
625625
objMN.pushKV("pubkeyoperator", dmn.pdmnState->pubKeyOperator.ToString());
626626
obj.pushKV(strOutpoint, objMN);
627627
} else if (strMode == "lastpaidblock") {
628-
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return;
628+
if (!strFilter.empty() && strOutpoint.find(strFilter) == std::string::npos) return;
629629
obj.pushKV(strOutpoint, dmn.pdmnState->nLastPaidHeight);
630630
} else if (strMode == "lastpaidtime") {
631-
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return;
631+
if (!strFilter.empty() && strOutpoint.find(strFilter) == std::string::npos) return;
632632
obj.pushKV(strOutpoint, dmnToLastPaidTime(dmn));
633633
} else if (strMode == "payee") {
634-
if (strFilter !="" && payeeStr.find(strFilter) == std::string::npos &&
634+
if (!strFilter.empty() && payeeStr.find(strFilter) == std::string::npos &&
635635
strOutpoint.find(strFilter) == std::string::npos) return;
636636
obj.pushKV(strOutpoint, payeeStr);
637637
} else if (strMode == "owneraddress") {
638-
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return;
638+
if (!strFilter.empty() && strOutpoint.find(strFilter) == std::string::npos) return;
639639
obj.pushKV(strOutpoint, EncodeDestination(PKHash(dmn.pdmnState->keyIDOwner)));
640640
} else if (strMode == "pubkeyoperator") {
641-
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return;
641+
if (!strFilter.empty() && strOutpoint.find(strFilter) == std::string::npos) return;
642642
obj.pushKV(strOutpoint, dmn.pdmnState->pubKeyOperator.ToString());
643643
} else if (strMode == "status") {
644644
std::string strStatus = dmnToStatus(dmn);
645-
if (strFilter !="" && strStatus.find(strFilter) == std::string::npos &&
645+
if (!strFilter.empty() && strStatus.find(strFilter) == std::string::npos &&
646646
strOutpoint.find(strFilter) == std::string::npos) return;
647647
obj.pushKV(strOutpoint, strStatus);
648648
} else if (strMode == "votingaddress") {
649-
if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return;
649+
if (!strFilter.empty() && strOutpoint.find(strFilter) == std::string::npos) return;
650650
obj.pushKV(strOutpoint, EncodeDestination(PKHash(dmn.pdmnState->keyIDVoting)));
651651
}
652652
});

0 commit comments

Comments
 (0)