Skip to content

Commit 67ca816

Browse files
Simplify "bool x = y ? true : false" to "bool x = y"
1 parent 9f841a6 commit 67ca816

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/blockencodings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
172172
bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const {
173173
assert(!header.IsNull());
174174
assert(index < txn_available.size());
175-
return txn_available[index] ? true : false;
175+
return txn_available[index] != nullptr;
176176
}
177177

178178
ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing) {

src/rpc/misc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ UniValue validateaddress(const JSONRPCRequest& request)
212212

213213
#ifdef ENABLE_WALLET
214214
isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO;
215-
ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
216-
ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
215+
ret.push_back(Pair("ismine", bool(mine & ISMINE_SPENDABLE)));
216+
ret.push_back(Pair("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)));
217217
UniValue detail = boost::apply_visitor(DescribeAddressVisitor(pwallet), dest);
218218
ret.pushKVs(detail);
219219
if (pwallet && pwallet->mapAddressBook.count(dest)) {

src/test/miner_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
260260
{
261261
tx.vout[0].nValue -= LOWFEE;
262262
hash = tx.GetHash();
263-
bool spendsCoinbase = (i == 0) ? true : false; // only first tx spends coinbase
263+
bool spendsCoinbase = i == 0; // only first tx spends coinbase
264264
// If we don't set the # of sig ops in the CTxMemPoolEntry, template creation fails
265265
mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
266266
tx.vin[0].prevout.hash = hash;
@@ -274,7 +274,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
274274
{
275275
tx.vout[0].nValue -= LOWFEE;
276276
hash = tx.GetHash();
277-
bool spendsCoinbase = (i == 0) ? true : false; // only first tx spends coinbase
277+
bool spendsCoinbase = i == 0; // only first tx spends coinbase
278278
// If we do set the # of sig ops in the CTxMemPoolEntry, template creation passes
279279
mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).SigOpsCost(80).FromTx(tx));
280280
tx.vin[0].prevout.hash = hash;
@@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
295295
{
296296
tx.vout[0].nValue -= LOWFEE;
297297
hash = tx.GetHash();
298-
bool spendsCoinbase = (i == 0) ? true : false; // only first tx spends coinbase
298+
bool spendsCoinbase = i == 0; // only first tx spends coinbase
299299
mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
300300
tx.vin[0].prevout.hash = hash;
301301
}

0 commit comments

Comments
 (0)