Skip to content

Commit b73370a

Browse files
committed
Remove unneeded test for nullptr
IntSimdMatrix::GetFastestMultiplier never returns a nullptr. Signed-off-by: Stefan Weil <[email protected]>
1 parent e2419b1 commit b73370a

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

src/arch/intsimdmatrix.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace tesseract {
2929
// available type for the current architecture.
3030
/* static */
3131
IntSimdMatrix* IntSimdMatrix::GetFastestMultiplier() {
32-
IntSimdMatrix* multiplier = nullptr;
32+
IntSimdMatrix* multiplier;
3333
if (SIMDDetect::IsAVX2Available()) {
3434
multiplier = new IntSimdMatrixAVX2();
3535
} else if (SIMDDetect::IsSSEAvailable()) {

src/lstm/networkio.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -987,11 +987,7 @@ void NetworkIO::ClipVector(int t, float range) {
987987
int NetworkIO::GetPadding(int num_features) {
988988
if (multiplier_ == nullptr)
989989
multiplier_ = IntSimdMatrix::GetFastestMultiplier();
990-
int pad = 0;
991-
if (multiplier_ != nullptr) {
992-
pad = multiplier_->RoundInputs(num_features) - num_features;
993-
}
994-
return pad;
990+
return multiplier_->RoundInputs(num_features) - num_features;
995991
}
996992

997993
} // namespace tesseract.

src/lstm/weightmatrix.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void WeightMatrix::ConvertToInt() {
169169
wf_.Resize(1, 1, 0.0);
170170
int_mode_ = true;
171171
multiplier_.reset(IntSimdMatrix::GetFastestMultiplier());
172-
if (multiplier_ != nullptr) multiplier_->Init(wi_);
172+
multiplier_->Init(wi_);
173173
}
174174

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

0 commit comments

Comments
 (0)