From 2c2cc5dac1102c1eb86c7dd825a893ab388abba1 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Mon, 8 Sep 2014 12:25:52 +0200 Subject: [PATCH] Remove some unnecessary c_strs() in logging and the GUI Includes `core: remove unneeded c_str() / Qt: replace c_str() with Qt code` by P. Kaufmann. --- src/addrman.h | 2 +- src/main.cpp | 4 ++-- src/net.cpp | 2 +- src/qt/coincontroldialog.cpp | 4 ++-- src/qt/walletmodel.cpp | 2 +- src/txmempool.cpp | 2 +- src/wallet.cpp | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/addrman.h b/src/addrman.h index 90507cb458..5fd698f18a 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -424,7 +424,7 @@ public: Check(); } if (fRet) - LogPrint("addrman", "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort().c_str(), source.ToString(), nTried, nNew); + LogPrint("addrman", "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort(), source.ToString(), nTried, nNew); return fRet; } diff --git a/src/main.cpp b/src/main.cpp index a3b31b719d..ff4560c2d0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4392,7 +4392,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (!pto->fDisconnect && state.nBlocksInFlight && state.nLastBlockReceive < state.nLastBlockProcess - BLOCK_DOWNLOAD_TIMEOUT*1000000 && state.vBlocksInFlight.front().nTime < state.nLastBlockProcess - 2*BLOCK_DOWNLOAD_TIMEOUT*1000000) { - LogPrintf("Peer %s is stalling block download, disconnecting\n", state.name.c_str()); + LogPrintf("Peer %s is stalling block download, disconnecting\n", state.name); pto->fDisconnect = true; } @@ -4502,7 +4502,7 @@ bool CBlockUndo::ReadFromDisk(const CDiskBlockPos &pos, const uint256 &hashBlock } std::string CBlockFileInfo::ToString() const { - return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst).c_str(), DateTimeStrFormat("%Y-%m-%d", nTimeLast).c_str()); + return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst), DateTimeStrFormat("%Y-%m-%d", nTimeLast)); } diff --git a/src/net.cpp b/src/net.cpp index 2546826f9a..633a3a34e7 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2114,7 +2114,7 @@ void CNode::AskFor(const CInv& inv) nRequestTime = it->second; else nRequestTime = 0; - LogPrint("net", "askfor %s %d (%s) peer=%d\n", inv.ToString(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str(), id); + LogPrint("net", "askfor %s %d (%s) peer=%d\n", inv.ToString(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000), id); // Make sure not to reuse time indexes to keep things in the same order int64_t nNow = GetTimeMicros() - 1000000; diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 7b30f8de09..d10463fd8f 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -705,7 +705,7 @@ void CoinControlDialog::updateView() QString sAddress = ""; if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, outputAddress)) { - sAddress = CBitcoinAddress(outputAddress).ToString().c_str(); + sAddress = QString::fromStdString(CBitcoinAddress(outputAddress).ToString()); // if listMode or change => show bitcoin address. In tree mode, address is not shown again for direct wallet address outputs if (!treeMode || (!(sAddress == sWalletAddress))) @@ -752,7 +752,7 @@ void CoinControlDialog::updateView() // transaction hash uint256 txhash = out.tx->GetHash(); - itemOutput->setText(COLUMN_TXHASH, txhash.GetHex().c_str()); + itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(txhash.GetHex())); // vout index itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i)); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 530c46cdb4..8d2c2e96d8 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -622,7 +622,7 @@ void WalletModel::listCoins(std::map >& mapCoins) CTxDestination address; if(!out.fSpendable || !ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address)) continue; - mapCoins[CBitcoinAddress(address).ToString().c_str()].push_back(out); + mapCoins[QString::fromStdString(CBitcoinAddress(address).ToString())].push_back(out); } } diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 238d5bab16..28339837bf 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -606,7 +606,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256 hash, const string strHash, deltas.first += dPriorityDelta; deltas.second += nFeeDelta; } - LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash.c_str(), dPriorityDelta, nFeeDelta); + LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash, dPriorityDelta, nFeeDelta); } void CTxMemPool::ApplyDeltas(const uint256 hash, double &dPriorityDelta, int64_t &nFeeDelta) diff --git a/src/wallet.cpp b/src/wallet.cpp index d3ad4869bb..c018c221b4 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -42,7 +42,7 @@ struct CompareValueOnly std::string COutput::ToString() const { - return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue).c_str()); + return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue)); } const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const