summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLogan Chien <tzuhsiang.chien@gmail.com>2016-08-26 02:06:27 +0800
committerLogan Chien <tzuhsiang.chien@gmail.com>2016-08-26 02:06:27 +0800
commiteb15a35ecbe2acd3437cff474686df8fde9bf42a (patch)
tree49fed51a2d20c30ce4377edbab83c9251d399388 /src
parente168e2b9b6dd099c97c7ec313c3062d80fa1a9a8 (diff)
downloadbinaryen-eb15a35ecbe2acd3437cff474686df8fde9bf42a.tar.gz
binaryen-eb15a35ecbe2acd3437cff474686df8fde9bf42a.tar.bz2
binaryen-eb15a35ecbe2acd3437cff474686df8fde9bf42a.zip
Replace std::unique<T>(new T()) with make_unique<T>().
This commit modernize the code base by replacing: std::unique_ptr<T>(new T(...)) with: make_unique<T>(...) or: wasm::make_unique<T>(...) This is a step closer to adopt C++14 std::make_unique<T>(...).
Diffstat (limited to 'src')
-rw-r--r--src/asm2wasm.h2
-rw-r--r--src/cfg/Relooper.cpp2
-rw-r--r--src/passes/LowerIfElse.cpp2
-rw-r--r--src/passes/LowerInt64.cpp2
-rw-r--r--src/support/threads.cpp7
-rw-r--r--src/wasm-module-building.h2
6 files changed, 9 insertions, 8 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index a5754f725..ce3c0749d 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -537,7 +537,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
for (unsigned i = 1; i < body->size(); i++) {
if (body[i][0] == DEFUN) numFunctions++;
}
- optimizingBuilder = std::unique_ptr<OptimizingIncrementalModuleBuilder>(new OptimizingIncrementalModuleBuilder(&wasm, numFunctions));
+ optimizingBuilder = make_unique<OptimizingIncrementalModuleBuilder>(&wasm, numFunctions);
}
// first pass - do almost everything, but function imports and indirect calls
diff --git a/src/cfg/Relooper.cpp b/src/cfg/Relooper.cpp
index cde61df0b..e75adbce5 100644
--- a/src/cfg/Relooper.cpp
+++ b/src/cfg/Relooper.cpp
@@ -98,7 +98,7 @@ Branch::Branch(wasm::Expression* ConditionInit, wasm::Expression* CodeInit) : An
Branch::Branch(std::vector<wasm::Index>&& ValuesInit, wasm::Expression* CodeInit) : Ancestor(nullptr), Code(CodeInit) {
if (ValuesInit.size() > 0) {
- SwitchValues = std::unique_ptr<std::vector<wasm::Index>>(new std::vector<wasm::Index>(ValuesInit));
+ SwitchValues = wasm::make_unique<std::vector<wasm::Index>>(ValuesInit);
}
// otherwise, it is the default
}
diff --git a/src/passes/LowerIfElse.cpp b/src/passes/LowerIfElse.cpp
index 7bdb2f419..b566e8207 100644
--- a/src/passes/LowerIfElse.cpp
+++ b/src/passes/LowerIfElse.cpp
@@ -38,7 +38,7 @@ struct LowerIfElse : public WalkerPass<PostWalker<LowerIfElse, Visitor<LowerIfEl
void prepare(PassRunner* runner, Module *module) override {
allocator = runner->allocator;
- namer = std::unique_ptr<NameManager>(new NameManager());
+ namer = make_unique<NameManager>();
namer->run(runner, module);
}
diff --git a/src/passes/LowerInt64.cpp b/src/passes/LowerInt64.cpp
index b59b1d5fc..69f6d5ae9 100644
--- a/src/passes/LowerInt64.cpp
+++ b/src/passes/LowerInt64.cpp
@@ -35,7 +35,7 @@ struct LowerInt64 : public Pass {
void prepare(PassRunner* runner, Module *module) override {
allocator = runner->allocator;
- namer = std::unique_ptr<NameManager>(new NameManager());
+ namer = make_unique<NameManager>();
namer->run(runner, module);
}
diff --git a/src/support/threads.cpp b/src/support/threads.cpp
index d9e8f8bf2..18f99d5ca 100644
--- a/src/support/threads.cpp
+++ b/src/support/threads.cpp
@@ -22,6 +22,7 @@
#include "threads.h"
#include "compiler-support.h"
+#include "utilities.h"
// debugging tools
@@ -47,7 +48,7 @@ static std::unique_ptr<ThreadPool> pool;
Thread::Thread() {
assert(!ThreadPool::get()->isRunning());
- thread = std::unique_ptr<std::thread>(new std::thread(mainLoop, this));
+ thread = make_unique<std::thread>(mainLoop, this);
}
Thread::~Thread() {
@@ -110,7 +111,7 @@ void ThreadPool::initialize(size_t num) {
ready.store(threads.size()); // initial state before first resetThreadsAreReady()
resetThreadsAreReady();
for (size_t i = 0; i < num; i++) {
- threads.emplace_back(std::unique_ptr<Thread>(new Thread()));
+ threads.emplace_back(make_unique<Thread>());
}
DEBUG_POOL("initialize() waiting\n");
condition.wait(lock, [this]() { return areThreadsReady(); });
@@ -127,7 +128,7 @@ size_t ThreadPool::getNumCores() {
ThreadPool* ThreadPool::get() {
if (!pool) {
- pool = std::unique_ptr<ThreadPool>(new ThreadPool());
+ pool = make_unique<ThreadPool>();
pool->initialize(getNumCores());
}
return pool.get();
diff --git a/src/wasm-module-building.h b/src/wasm-module-building.h
index 3cdebc558..1d181277f 100644
--- a/src/wasm-module-building.h
+++ b/src/wasm-module-building.h
@@ -139,7 +139,7 @@ public:
private:
void createWorker() {
DEBUG_THREAD("create a worker");
- threads.emplace_back(std::unique_ptr<std::thread>(new std::thread(workerMain, this)));
+ threads.emplace_back(make_unique<std::thread>(workerMain, this));
}
void wakeWorker() {