Skip to content

Commit

Permalink
Fix wrong comparison
Browse files Browse the repository at this point in the history
symbol_steps is a vector, so testing for a nullptr was wrong.

clang++ reports:

    ..\src\ccmain\ltrresultiterator.cpp(440,19):  warning: comparison of address of 'this->word_res_->symbol_steps' equal to a null pointer is always false [-Wtautological-pointer-compare]
      if (&word_res_->symbol_steps == nullptr || !LSTM_mode_) return nullptr;
           ~~~~~~~~~~~^~~~~~~~~~~~    ~~~~~~~

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Mar 13, 2019
1 parent 681e630 commit ed84ba0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/ccmain/ltrresultiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Description: Iterator for tesseract results in strict left-to-right
// order that avoids using tesseract internal data structures.
// Author: Ray Smith
// Created: Fri Feb 26 14:32:09 PST 2010
//
// (C) Copyright 2010, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -437,7 +436,7 @@ float ChoiceIterator::Confidence() const {
// Returns the set of timesteps which belong to the current symbol
std::vector<std::vector<std::pair<const char*, float>>>*
ChoiceIterator::Timesteps() const {
if (&word_res_->symbol_steps == nullptr || !LSTM_mode_) return nullptr;
if (word_res_->symbol_steps.empty() || !LSTM_mode_) return nullptr;
if (word_res_->leadingSpace) {
return &word_res_->symbol_steps[*(tstep_index_) + 1];
} else {
Expand Down

0 comments on commit ed84ba0

Please sign in to comment.