Skip to content

Commit

Permalink
Remove unneeded test for nullptr
Browse files Browse the repository at this point in the history
IntSimdMatrix::GetFastestMultiplier never returns a nullptr.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Nov 30, 2018
1 parent e2419b1 commit b73370a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/arch/intsimdmatrix.cpp
Expand Up @@ -29,7 +29,7 @@ namespace tesseract {
// available type for the current architecture.
/* static */
IntSimdMatrix* IntSimdMatrix::GetFastestMultiplier() {
IntSimdMatrix* multiplier = nullptr;
IntSimdMatrix* multiplier;
if (SIMDDetect::IsAVX2Available()) {
multiplier = new IntSimdMatrixAVX2();
} else if (SIMDDetect::IsSSEAvailable()) {
Expand Down
6 changes: 1 addition & 5 deletions src/lstm/networkio.cpp
Expand Up @@ -987,11 +987,7 @@ void NetworkIO::ClipVector(int t, float range) {
int NetworkIO::GetPadding(int num_features) {
if (multiplier_ == nullptr)
multiplier_ = IntSimdMatrix::GetFastestMultiplier();
int pad = 0;
if (multiplier_ != nullptr) {
pad = multiplier_->RoundInputs(num_features) - num_features;
}
return pad;
return multiplier_->RoundInputs(num_features) - num_features;
}

} // namespace tesseract.
4 changes: 2 additions & 2 deletions src/lstm/weightmatrix.cpp
Expand Up @@ -169,7 +169,7 @@ void WeightMatrix::ConvertToInt() {
wf_.Resize(1, 1, 0.0);
int_mode_ = true;
multiplier_.reset(IntSimdMatrix::GetFastestMultiplier());
if (multiplier_ != nullptr) multiplier_->Init(wi_);
multiplier_->Init(wi_);
}

// Allocates any needed memory for running Backward, and zeroes the deltas,
Expand Down Expand Up @@ -222,7 +222,7 @@ bool WeightMatrix::DeSerialize(bool training, TFile* fp) {
if (!wi_.DeSerialize(fp)) return false;
if (!scales_.DeSerialize(fp)) return false;
multiplier_.reset(IntSimdMatrix::GetFastestMultiplier());
if (multiplier_ != nullptr) multiplier_->Init(wi_);
multiplier_->Init(wi_);
} else {
if (!wf_.DeSerialize(fp)) return false;
if (training) {
Expand Down

0 comments on commit b73370a

Please sign in to comment.