Skip to content

Commit 7aa40f5

Browse files
committed
refactor: use C++11 default initializers
1 parent d5d40d5 commit 7aa40f5

39 files changed

+57
-88
lines changed

src/bench/checkqueue.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
3030

3131
struct PrevectorJob {
3232
prevector<PREVECTOR_SIZE, uint8_t> p;
33-
PrevectorJob(){
34-
}
33+
PrevectorJob() = default;
3534
explicit PrevectorJob(FastRandomContext& insecure_rand){
3635
p.resize(insecure_rand.randrange(PREVECTOR_SIZE*2));
3736
}

src/bench/prevector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <bench/bench.h>
1111

1212
struct nontrivial_t {
13-
int x;
14-
nontrivial_t() :x(-1) {}
13+
int x{-1};
14+
nontrivial_t() = default;
1515
SERIALIZE_METHODS(nontrivial_t, obj) { READWRITE(obj.x); }
1616
};
1717
static_assert(!std::is_trivially_default_constructible<nontrivial_t>::value,

src/bitcoin-cli.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ static int AppInitRPC(int argc, char* argv[])
180180
/** Reply structure for request_done to fill in */
181181
struct HTTPReply
182182
{
183-
HTTPReply(): status(0), error(-1) {}
183+
HTTPReply() = default;
184184

185-
int status;
186-
int error;
185+
int status{0};
186+
int error{-1};
187187
std::string body;
188188
};
189189

@@ -244,7 +244,7 @@ static void http_error_cb(enum evhttp_request_error err, void *ctx)
244244
class BaseRequestHandler
245245
{
246246
public:
247-
virtual ~BaseRequestHandler() {}
247+
virtual ~BaseRequestHandler() = default;
248248
virtual UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) = 0;
249249
virtual UniValue ProcessReply(const UniValue &batch_in) = 0;
250250
};

src/httpserver.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,16 @@ class WorkQueue
7373
Mutex cs;
7474
std::condition_variable cond GUARDED_BY(cs);
7575
std::deque<std::unique_ptr<WorkItem>> queue GUARDED_BY(cs);
76-
bool running GUARDED_BY(cs);
76+
bool running GUARDED_BY(cs){true};
7777
const size_t maxDepth;
7878

7979
public:
80-
explicit WorkQueue(size_t _maxDepth) : running(true),
81-
maxDepth(_maxDepth)
80+
explicit WorkQueue(size_t _maxDepth) : maxDepth(_maxDepth)
8281
{
8382
}
8483
/** Precondition: worker threads have all stopped (they have been joined).
8584
*/
86-
~WorkQueue()
87-
{
88-
}
85+
~WorkQueue() = default;
8986
/** Enqueue a work item */
9087
bool Enqueue(WorkItem* item) EXCLUSIVE_LOCKS_REQUIRED(!cs)
9188
{

src/index/txindex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ TxIndex::TxIndex(size_t n_cache_size, bool f_memory, bool f_wipe)
5252
: m_db(std::make_unique<TxIndex::DB>(n_cache_size, f_memory, f_wipe))
5353
{}
5454

55-
TxIndex::~TxIndex() {}
55+
TxIndex::~TxIndex() = default;
5656

5757
bool TxIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex)
5858
{

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2691,7 +2691,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
26912691
class CNetCleanup
26922692
{
26932693
public:
2694-
CNetCleanup() {}
2694+
CNetCleanup() = default;
26952695

26962696
~CNetCleanup()
26972697
{

src/netaddress.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ bool CNetAddr::SetNetFromBIP155Network(uint8_t possible_bip155_net, size_t addre
9898
*
9999
* @note This address is considered invalid by CNetAddr::IsValid()
100100
*/
101-
CNetAddr::CNetAddr() {}
101+
CNetAddr::CNetAddr() = default;
102102

103103
void CNetAddr::SetIP(const CNetAddr& ipIn)
104104
{

src/node/context.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
#include <validation.h>
1717

1818
namespace node {
19-
NodeContext::NodeContext() {}
20-
NodeContext::~NodeContext() {}
19+
NodeContext::NodeContext() = default;
20+
NodeContext::~NodeContext() = default;
2121
} // namespace node

src/policy/fees.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,7 @@ CBlockPolicyEstimator::CBlockPolicyEstimator()
537537
}
538538
}
539539

540-
CBlockPolicyEstimator::~CBlockPolicyEstimator()
541-
{
542-
}
540+
CBlockPolicyEstimator::~CBlockPolicyEstimator() = default;
543541

544542
void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry& entry, bool validFeeEstimate)
545543
{

src/qt/addresstablemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct AddressTableEntry
3030
QString label;
3131
QString address;
3232

33-
AddressTableEntry() {}
33+
AddressTableEntry() = default;
3434
AddressTableEntry(Type _type, const QString &_label, const QString &_address):
3535
type(_type), label(_label), address(_address) {}
3636
};

0 commit comments

Comments
 (0)