Skip to content

Commit 3ba2840

Browse files
committed
scripted-diff: remove MakeUnique<T>()
-BEGIN VERIFY SCRIPT- git rm src/util/memory.h sed -i -e 's/MakeUnique/std::make_unique/g' $(git grep -l MakeUnique src) sed -i -e '/#include <util\/memory.h>/d' $(git grep -l '#include <util/memory.h>' src) sed -i -e '/util\/memory.h \\/d' src/Makefile.am -END VERIFY SCRIPT-
1 parent 63314b8 commit 3ba2840

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+110
-156
lines changed

src/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ BITCOIN_CORE_H = \
240240
util/golombrice.h \
241241
util/hasher.h \
242242
util/macros.h \
243-
util/memory.h \
244243
util/message.h \
245244
util/moneystr.h \
246245
util/rbf.h \

src/bench/coin_selection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<st
1717
tx.nLockTime = nextLockTime++; // so all transactions get different hashes
1818
tx.vout.resize(1);
1919
tx.vout[0].nValue = nValue;
20-
wtxs.push_back(MakeUnique<CWalletTx>(&wallet, MakeTransactionRef(std::move(tx))));
20+
wtxs.push_back(std::make_unique<CWalletTx>(&wallet, MakeTransactionRef(std::move(tx))));
2121
}
2222

2323
// Simple benchmark for wallet coin selection. Note that it maybe be necessary
@@ -73,7 +73,7 @@ static void add_coin(const CAmount& nValue, int nInput, std::vector<OutputGroup>
7373
CMutableTransaction tx;
7474
tx.vout.resize(nInput + 1);
7575
tx.vout[nInput].nValue = nValue;
76-
std::unique_ptr<CWalletTx> wtx = MakeUnique<CWalletTx>(&testWallet, MakeTransactionRef(std::move(tx)));
76+
std::unique_ptr<CWalletTx> wtx = std::make_unique<CWalletTx>(&testWallet, MakeTransactionRef(std::move(tx)));
7777
set.emplace_back();
7878
set.back().Insert(COutput(wtx.get(), nInput, 0, true, true, true).GetInputCoin(), 0, true, 0, 0, false);
7979
wtxn.emplace_back(std::move(wtx));

src/chainparamsbase.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include <tinyformat.h>
99
#include <util/system.h>
10-
#include <util/memory.h>
1110

1211
#include <assert.h>
1312

@@ -44,13 +43,13 @@ const CBaseChainParams& BaseParams()
4443
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
4544
{
4645
if (chain == CBaseChainParams::MAIN) {
47-
return MakeUnique<CBaseChainParams>("", 8332, 8334);
46+
return std::make_unique<CBaseChainParams>("", 8332, 8334);
4847
} else if (chain == CBaseChainParams::TESTNET) {
49-
return MakeUnique<CBaseChainParams>("testnet3", 18332, 18334);
48+
return std::make_unique<CBaseChainParams>("testnet3", 18332, 18334);
5049
} else if (chain == CBaseChainParams::SIGNET) {
51-
return MakeUnique<CBaseChainParams>("signet", 38332, 38334);
50+
return std::make_unique<CBaseChainParams>("signet", 38332, 38334);
5251
} else if (chain == CBaseChainParams::REGTEST) {
53-
return MakeUnique<CBaseChainParams>("regtest", 18443, 18445);
52+
return std::make_unique<CBaseChainParams>("regtest", 18443, 18445);
5453
}
5554
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
5655
}

src/httprpc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ bool StartHTTPRPC(const util::Ref& context)
301301
}
302302
struct event_base* eventBase = EventBase();
303303
assert(eventBase);
304-
httpRPCTimerInterface = MakeUnique<HTTPRPCTimerInterface>(eventBase);
304+
httpRPCTimerInterface = std::make_unique<HTTPRPCTimerInterface>(eventBase);
305305
RPCSetTimerInterface(httpRPCTimerInterface.get());
306306
return true;
307307
}

src/index/blockfilterindex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ BlockFilterIndex::BlockFilterIndex(BlockFilterType filter_type,
102102
fs::create_directories(path);
103103

104104
m_name = filter_name + " block filter index";
105-
m_db = MakeUnique<BaseIndex::DB>(path / "db", n_cache_size, f_memory, f_wipe);
106-
m_filter_fileseq = MakeUnique<FlatFileSeq>(std::move(path), "fltr", FLTR_FILE_CHUNK_SIZE);
105+
m_db = std::make_unique<BaseIndex::DB>(path / "db", n_cache_size, f_memory, f_wipe);
106+
m_filter_fileseq = std::make_unique<FlatFileSeq>(std::move(path), "fltr", FLTR_FILE_CHUNK_SIZE);
107107
}
108108

109109
bool BlockFilterIndex::Init()

src/index/txindex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ bool TxIndex::DB::MigrateData(CBlockTreeDB& block_tree_db, const CBlockLocator&
192192
}
193193

194194
TxIndex::TxIndex(size_t n_cache_size, bool f_memory, bool f_wipe)
195-
: m_db(MakeUnique<TxIndex::DB>(n_cache_size, f_memory, f_wipe))
195+
: m_db(std::make_unique<TxIndex::DB>(n_cache_size, f_memory, f_wipe))
196196
{}
197197

198198
TxIndex::~TxIndex() {}

src/init.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
13491349
}
13501350

13511351
assert(!node.scheduler);
1352-
node.scheduler = MakeUnique<CScheduler>();
1352+
node.scheduler = std::make_unique<CScheduler>();
13531353

13541354
// Start the lightweight task scheduler thread
13551355
node.scheduler->m_service_thread = std::thread([&] { TraceThread("scheduler", [&] { node.scheduler->serviceQueue(); }); });
@@ -1401,9 +1401,9 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
14011401
const bool ignores_incoming_txs{args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)};
14021402

14031403
assert(!node.banman);
1404-
node.banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
1404+
node.banman = std::make_unique<BanMan>(GetDataDir() / "banlist.dat", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
14051405
assert(!node.connman);
1406-
node.connman = MakeUnique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()), args.GetBoolArg("-networkactive", true));
1406+
node.connman = std::make_unique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()), args.GetBoolArg("-networkactive", true));
14071407

14081408
assert(!node.fee_estimator);
14091409
// Don't initialize fee estimation with old data if we don't relay transactions,
@@ -1799,7 +1799,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
17991799

18001800
// ********************************************************* Step 8: start indexers
18011801
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
1802-
g_txindex = MakeUnique<TxIndex>(nTxIndexCache, false, fReindex);
1802+
g_txindex = std::make_unique<TxIndex>(nTxIndexCache, false, fReindex);
18031803
g_txindex->Start();
18041804
}
18051805

src/interfaces/handler.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <interfaces/handler.h>
66

7-
#include <util/memory.h>
87

98
#include <boost/signals2/connection.hpp>
109
#include <utility>
@@ -35,12 +34,12 @@ class CleanupHandler : public Handler
3534

3635
std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection)
3736
{
38-
return MakeUnique<HandlerImpl>(std::move(connection));
37+
return std::make_unique<HandlerImpl>(std::move(connection));
3938
}
4039

4140
std::unique_ptr<Handler> MakeHandler(std::function<void()> cleanup)
4241
{
43-
return MakeUnique<CleanupHandler>(std::move(cleanup));
42+
return std::make_unique<CleanupHandler>(std::move(cleanup));
4443
}
4544

4645
} // namespace interfaces

src/net.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,11 +2466,11 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
24662466

24672467
if (semOutbound == nullptr) {
24682468
// initialize semaphore
2469-
semOutbound = MakeUnique<CSemaphore>(std::min(m_max_outbound, nMaxConnections));
2469+
semOutbound = std::make_unique<CSemaphore>(std::min(m_max_outbound, nMaxConnections));
24702470
}
24712471
if (semAddnode == nullptr) {
24722472
// initialize semaphore
2473-
semAddnode = MakeUnique<CSemaphore>(nMaxAddnode);
2473+
semAddnode = std::make_unique<CSemaphore>(nMaxAddnode);
24742474
}
24752475

24762476
//
@@ -2906,11 +2906,11 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const
29062906
hSocket = hSocketIn;
29072907
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
29082908
if (conn_type_in != ConnectionType::BLOCK_RELAY) {
2909-
m_tx_relay = MakeUnique<TxRelay>();
2909+
m_tx_relay = std::make_unique<TxRelay>();
29102910
}
29112911

29122912
if (RelayAddrsWithConn()) {
2913-
m_addr_known = MakeUnique<CRollingBloomFilter>(5000, 0.001);
2913+
m_addr_known = std::make_unique<CRollingBloomFilter>(5000, 0.001);
29142914
}
29152915

29162916
for (const std::string &msg : getAllNetMessageTypes())
@@ -2923,8 +2923,8 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const
29232923
LogPrint(BCLog::NET, "Added connection peer=%d\n", id);
29242924
}
29252925

2926-
m_deserializer = MakeUnique<V1TransportDeserializer>(V1TransportDeserializer(Params(), GetId(), SER_NETWORK, INIT_PROTO_VERSION));
2927-
m_serializer = MakeUnique<V1TransportSerializer>(V1TransportSerializer());
2926+
m_deserializer = std::make_unique<V1TransportDeserializer>(V1TransportDeserializer(Params(), GetId(), SER_NETWORK, INIT_PROTO_VERSION));
2927+
m_serializer = std::make_unique<V1TransportSerializer>(V1TransportSerializer());
29282928
}
29292929

29302930
CNode::~CNode()

src/node/interfaces.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ class ChainImpl : public Chain
613613
}
614614
std::unique_ptr<Handler> handleNotifications(std::shared_ptr<Notifications> notifications) override
615615
{
616-
return MakeUnique<NotificationsHandlerImpl>(std::move(notifications));
616+
return std::make_unique<NotificationsHandlerImpl>(std::move(notifications));
617617
}
618618
void waitForNotificationsIfTipChanged(const uint256& old_tip) override
619619
{
@@ -626,7 +626,7 @@ class ChainImpl : public Chain
626626
}
627627
std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) override
628628
{
629-
return MakeUnique<RpcHandlerImpl>(command);
629+
return std::make_unique<RpcHandlerImpl>(command);
630630
}
631631
bool rpcEnableDeprecated(const std::string& method) override { return IsDeprecatedRPCEnabled(method); }
632632
void rpcRunLater(const std::string& name, std::function<void()> fn, int64_t seconds) override
@@ -669,6 +669,6 @@ class ChainImpl : public Chain
669669
} // namespace node
670670

671671
namespace interfaces {
672-
std::unique_ptr<Node> MakeNode(NodeContext* context) { return MakeUnique<node::NodeImpl>(context); }
673-
std::unique_ptr<Chain> MakeChain(NodeContext& context) { return MakeUnique<node::ChainImpl>(context); }
672+
std::unique_ptr<Node> MakeNode(NodeContext* context) { return std::make_unique<node::NodeImpl>(context); }
673+
std::unique_ptr<Chain> MakeChain(NodeContext& context) { return std::make_unique<node::ChainImpl>(context); }
674674
} // namespace interfaces

0 commit comments

Comments
 (0)