Skip to content

Commit 2e04864

Browse files
authored
Replace boost::lexical_cast<int> with atoi (#1926)
Also cleanup existing atoi-s in Dash code
1 parent 0f4d963 commit 2e04864

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,10 +1809,10 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
18091809
LOCK(pwalletMain->cs_wallet);
18101810
LogPrintf("Locking Masternodes:\n");
18111811
uint256 mnTxHash;
1812-
int outputIndex;
1812+
uint32_t outputIndex;
18131813
for (const auto& mne : masternodeConfig.getEntries()) {
18141814
mnTxHash.SetHex(mne.getTxHash());
1815-
outputIndex = boost::lexical_cast<unsigned int>(mne.getOutputIndex());
1815+
outputIndex = (uint32_t)atoi(mne.getOutputIndex());
18161816
COutPoint outpoint = COutPoint(mnTxHash, outputIndex);
18171817
// don't lock non-spendable outpoint (i.e. it's already spent or it's not from this wallet at all)
18181818
if(pwalletMain->IsMine(CTxIn(outpoint)) != ISMINE_SPENDABLE) {

src/rpc/governance.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#include "wallet/wallet.h"
2525
#endif // ENABLE_WALLET
2626

27-
#include <boost/lexical_cast.hpp>
28-
2927
UniValue gobject(const JSONRPCRequest& request)
3028
{
3129
std::string strCommand;
@@ -144,8 +142,8 @@ UniValue gobject(const JSONRPCRequest& request)
144142

145143
std::string strRevision = request.params[2].get_str();
146144
std::string strTime = request.params[3].get_str();
147-
int nRevision = boost::lexical_cast<int>(strRevision);
148-
int nTime = boost::lexical_cast<int>(strTime);
145+
int nRevision = atoi(strRevision);
146+
int64_t nTime = atoi64(strTime);
149147
std::string strData = request.params[4].get_str();
150148

151149
// CREATE A NEW COLLATERAL TRANSACTION FOR THIS SPECIFIC OBJECT
@@ -230,8 +228,8 @@ UniValue gobject(const JSONRPCRequest& request)
230228

231229
std::string strRevision = request.params[2].get_str();
232230
std::string strTime = request.params[3].get_str();
233-
int nRevision = boost::lexical_cast<int>(strRevision);
234-
int nTime = boost::lexical_cast<int>(strTime);
231+
int nRevision = atoi(strRevision);
232+
int64_t nTime = atoi64(strTime);
235233
std::string strData = request.params[4].get_str();
236234

237235
CGovernanceObject govobj(hashParent, nRevision, nTime, txidFee, strData);
@@ -817,8 +815,7 @@ UniValue gobject(const JSONRPCRequest& request)
817815
if (request.params.size() == 4) {
818816
uint256 txid = ParseHashV(request.params[2], "Masternode Collateral hash");
819817
std::string strVout = request.params[3].get_str();
820-
uint32_t vout = boost::lexical_cast<uint32_t>(strVout);
821-
mnCollateralOutpoint = COutPoint(txid, vout);
818+
mnCollateralOutpoint = COutPoint(txid, (uint32_t)atoi(strVout));
822819
}
823820

824821
// FIND OBJECT USER IS LOOKING FOR

src/rpc/masternode.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ UniValue masternode(const JSONRPCRequest& request)
317317
for (const auto& mne : masternodeConfig.getEntries()) {
318318
std::string strError;
319319

320-
COutPoint outpoint = COutPoint(uint256S(mne.getTxHash()), uint32_t(atoi(mne.getOutputIndex().c_str())));
320+
COutPoint outpoint = COutPoint(uint256S(mne.getTxHash()), (uint32_t)atoi(mne.getOutputIndex()));
321321
CMasternode mn;
322322
bool fFound = mnodeman.Get(outpoint, mn);
323323
CMasternodeBroadcast mnb;
@@ -365,7 +365,7 @@ UniValue masternode(const JSONRPCRequest& request)
365365
UniValue resultObj(UniValue::VOBJ);
366366

367367
for (const auto& mne : masternodeConfig.getEntries()) {
368-
COutPoint outpoint = COutPoint(uint256S(mne.getTxHash()), uint32_t(atoi(mne.getOutputIndex().c_str())));
368+
COutPoint outpoint = COutPoint(uint256S(mne.getTxHash()), (uint32_t)atoi(mne.getOutputIndex()));
369369
CMasternode mn;
370370
bool fFound = mnodeman.Get(outpoint, mn);
371371

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3229,7 +3229,7 @@ bool CWallet::GetMasternodeOutpointAndKeys(COutPoint& outpointRet, CPubKey& pubK
32293229

32303230
// Find specific vin
32313231
uint256 txHash = uint256S(strTxHash);
3232-
int nOutputIndex = atoi(strOutputIndex.c_str());
3232+
int nOutputIndex = atoi(strOutputIndex);
32333233

32343234
for (const auto& out : vPossibleCoins)
32353235
if(out.tx->GetHash() == txHash && out.i == nOutputIndex) // found it!

0 commit comments

Comments
 (0)