Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useless empty pointer check. #2862

Merged
merged 1 commit into from
Jul 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions paddle/api/ConfigParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ ModelConfig* TrainerConfig::getModelConfig() const {

ParameterConfig::ParameterConfig() : m(new ParameterConfigPrivate()) {}

ParameterConfig::~ParameterConfig() {
if (m) {
delete m;
}
}
ParameterConfig::~ParameterConfig() { delete m; }

ParameterConfig* ParameterConfig::createParameterConfigFromParameterSharedPtr(
void* ptr) {
Expand Down Expand Up @@ -98,11 +94,7 @@ void* ParameterConfig::getRawPtr() { return m->getConfigPtr(); }

OptimizationConfig::OptimizationConfig() : m(new OptimizationConfigPrivate()) {}

OptimizationConfig::~OptimizationConfig() {
if (m) {
delete m;
}
}
OptimizationConfig::~OptimizationConfig() { delete m; }

std::string OptimizationConfig::toProtoString() {
return m->getConfig().SerializeAsString();
Expand Down
12 changes: 2 additions & 10 deletions paddle/api/ParameterOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ struct ParameterTraverseCallbackPrivate {

ParameterOptimizer::ParameterOptimizer() : m(new ParameterOptimizerPrivate()) {}

ParameterOptimizer::~ParameterOptimizer() {
if (m) {
delete m;
}
}
ParameterOptimizer::~ParameterOptimizer() { delete m; }

ParameterOptimizer* ParameterOptimizer::create(OptimizationConfig* config) {
CHECK(config != nullptr);
Expand Down Expand Up @@ -104,11 +100,7 @@ std::vector<int> ParameterOptimizer::getParameterTypes() const {
ParameterTraverseCallback::ParameterTraverseCallback()
: m(new ParameterTraverseCallbackPrivate()) {}

ParameterTraverseCallback::~ParameterTraverseCallback() {
if (m) {
delete m;
}
}
ParameterTraverseCallback::~ParameterTraverseCallback() { delete m; }

void ParameterTraverseCallback::apply(const std::vector<Vector*>& vecs,
const ParameterConfig& conf,
Expand Down
6 changes: 1 addition & 5 deletions paddle/api/Vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ struct VectorPrivate {

Vector::Vector() : m(new VectorPrivate()) {}

Vector::~Vector() {
if (m) {
delete m;
}
}
Vector::~Vector() { delete m; }

Vector* Vector::createZero(size_t sz, bool useGpu) {
auto retVec = new Vector();
Expand Down
6 changes: 2 additions & 4 deletions paddle/gserver/dataproviders/DataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,8 @@ class BufferBatch {
hl_destroy_event(hlEvent_);
hlEvent_ = NULL;
}
if (batchData_) {
delete batchData_;
batchData_ = NULL;
}
delete batchData_;
batchData_ = NULL;
}

void setDataBatch(DataBatch* batchData) { batchData_ = batchData; }
Expand Down
4 changes: 1 addition & 3 deletions paddle/math/Storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ static InitFunction __init_storage_engine([]() { StorageEngine::singleton(); },
StorageEngine::StorageEngine() : cpuAllocator_(nullptr) {}

StorageEngine::~StorageEngine() {
if (cpuAllocator_) {
delete cpuAllocator_;
}
delete cpuAllocator_;
for (auto it : gpuAllocator_) {
delete it;
}
Expand Down
6 changes: 1 addition & 5 deletions paddle/trainer/TrainerConfigHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ TrainerConfigHelper::TrainerConfigHelper(const TrainerConfig &config)
m->conf = config;
}

TrainerConfigHelper::~TrainerConfigHelper() {
if (m) {
delete m;
}
}
TrainerConfigHelper::~TrainerConfigHelper() { delete m; }

const TrainerConfig &TrainerConfigHelper::getConfig() const { return m->conf; }

Expand Down