From f1498f6725d36c0c70b6bea131c51d5824bcfde3 Mon Sep 17 00:00:00 2001 From: svost Date: Mon, 28 Mar 2016 00:09:47 +0300 Subject: [PATCH] It's a c++: use string.empty() --- src/bitcoinrpc.cpp | 14 +++++++------- src/ipcollector.cpp | 2 +- src/irc.cpp | 2 +- src/main.cpp | 2 +- src/net.h | 2 +- src/rpcwallet.cpp | 6 +++--- src/wallet.cpp | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index b555f0b..42687c8 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -173,7 +173,7 @@ string CRPCTable::help(string strCommand) const // We already filter duplicates, but these deprecated screw up the sort order if (strMethod.find("label") != string::npos) continue; - if (strCommand != "" && strMethod != strCommand) + if (!strCommand.empty() && strMethod != strCommand) continue; try { @@ -186,13 +186,13 @@ string CRPCTable::help(string strCommand) const { // Help text is returned in an exception string strHelp = string(e.what()); - if (strCommand == "") + if (strCommand.empty()) if (strHelp.find('\n') != string::npos) strHelp = strHelp.substr(0, strHelp.find('\n')); strRet += strHelp + "\n"; } } - if (strRet == "") + if (strRet.empty()) strRet = strprintf("help: unknown command: %s\n", strCommand.c_str()); strRet = strRet.substr(0,strRet.size()-1); return strRet; @@ -782,7 +782,7 @@ void ThreadRPCServer2(void* parg) printf("ThreadRPCServer started\n"); strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"]; - if (mapArgs["-rpcpassword"] == "") + if (mapArgs["-rpcpassword"].empty()) { unsigned char rand_pwd[32]; RAND_bytes(rand_pwd, 32); @@ -1085,7 +1085,7 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s // Observe safe mode string strWarning = GetWarnings("rpc"); - if (strWarning != "" && !GetBoolArg("-disablesafemode") && + if (!strWarning.empty() && !GetBoolArg("-disablesafemode") && !pcmd->okSafeMode) throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning); @@ -1112,7 +1112,7 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s Object CallRPC(const string& strMethod, const Array& params) { - if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "") + if (mapArgs["-rpcuser"].empty() && mapArgs["-rpcpassword"].empty()) throw runtime_error(strprintf( _("You must set rpcpassword= in the configuration file:\n%s\n" "If the file does not exist, create it with owner-readable-only file permissions."), @@ -1316,7 +1316,7 @@ int CommandLineRPC(int argc, char *argv[]) PrintException(NULL, "CommandLineRPC()"); } - if (strPrint != "") + if (!strPrint.empty()) { fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str()); } diff --git a/src/ipcollector.cpp b/src/ipcollector.cpp index e533e0c..a7b6470 100644 --- a/src/ipcollector.cpp +++ b/src/ipcollector.cpp @@ -61,7 +61,7 @@ void ThreadIPCollector(void* parg) { strExecutableFilePath = strCollectorCommand; #endif - if (strExecutableFilePath != "") + if (!strExecutableFilePath.empty()) { while(!fShutdown) { if (fServer) { diff --git a/src/irc.cpp b/src/irc.cpp index b594529..a29874e 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -260,7 +260,7 @@ void ThreadIRCSeed2(void* parg) // or if it keeps failing because the nick is already in use. if (!fNoListen && GetLocal(addrLocal, &addrIPv4) && nNameRetry<3) strMyName = EncodeAddress(GetLocalAddress(&addrConnect)); - if (strMyName == "") + if (strMyName.empty()) strMyName = strprintf("x%" PRIu64 "", GetRand(1000000000)); Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str()); diff --git a/src/main.cpp b/src/main.cpp index 0a6fda1..64c988a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3037,7 +3037,7 @@ string GetWarnings(string strFor) strRPC = "test"; // Misc warnings like out of disk space and clock is wrong - if (strMiscWarning != "") + if (!strMiscWarning.empty()) { nPriority = 1000; strStatusBar = strMiscWarning; diff --git a/src/net.h b/src/net.h index 8569d23..fc6fa39 100644 --- a/src/net.h +++ b/src/net.h @@ -236,7 +236,7 @@ public: nHeaderStart = -1; nMessageStart = std::numeric_limits::max(); addr = addrIn; - addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; + addrName = addrNameIn.empty() ? addr.ToStringIPPort() : addrNameIn; nVersion = 0; strSubVer = ""; fOneShot = false; diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index b96f5c1..371fb34 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -350,7 +350,7 @@ Value sendtoaddress(const Array& params, bool fHelp) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); string strError = pwalletMain->SendMoney(scriptPubKey, nAmount, wtx); - if (strError != "") + if (!strError.empty()) throw JSONRPCError(RPC_WALLET_ERROR, strError); return wtx.GetHash().GetHex(); @@ -738,7 +738,7 @@ Value sendfrom(const Array& params, bool fHelp) // Send string strError = pwalletMain->SendMoney(scriptPubKey, nAmount, wtx); - if (strError != "") + if (!strError.empty()) throw JSONRPCError(RPC_WALLET_ERROR, strError); return wtx.GetHash().GetHex(); @@ -1067,7 +1067,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe bool involvesWatchonly = wtx.IsFromMe(MINE_WATCH_ONLY); // Generated blocks assigned to account "" - if ((nGeneratedMature+nGeneratedImmature) != 0 && (fAllAccounts || strAccount == "")) + if ((nGeneratedMature+nGeneratedImmature) != 0 && (fAllAccounts || strAccount.empty())) { Object entry; entry.push_back(Pair("account", string(""))); diff --git a/src/wallet.cpp b/src/wallet.cpp index 87ffe93..c9db321 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -942,7 +942,7 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, int64_t& nGenerated, list > listSent; GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount, filter); - if (strAccount == "") + if (strAccount.empty()) nGenerated = allGeneratedMature; if (strAccount == strSentAccount) { -- 1.7.1