Skip to content

Commit

Permalink
Remove unnecessary assignment and assertions
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Sep 3, 2024
1 parent 027ad18 commit 1b22245
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/ccmain/ltrresultiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,11 @@ float LTRResultIterator::Confidence(PageIteratorLevel level) const {
float mean_certainty = 0.0f;
int certainty_count = 0;
PAGE_RES_IT res_it(*it_);
WERD_CHOICE *best_choice = res_it.word()->best_choice;
ASSERT_HOST(best_choice != nullptr);
WERD_CHOICE *best_choice;
switch (level) {
case RIL_BLOCK:
do {
best_choice = res_it.word()->best_choice;
ASSERT_HOST(best_choice != nullptr);
mean_certainty += best_choice->certainty();
++certainty_count;
res_it.forward();
Expand All @@ -114,7 +112,6 @@ float LTRResultIterator::Confidence(PageIteratorLevel level) const {
case RIL_PARA:
do {
best_choice = res_it.word()->best_choice;
ASSERT_HOST(best_choice != nullptr);
mean_certainty += best_choice->certainty();
++certainty_count;
res_it.forward();
Expand All @@ -124,19 +121,20 @@ float LTRResultIterator::Confidence(PageIteratorLevel level) const {
case RIL_TEXTLINE:
do {
best_choice = res_it.word()->best_choice;
ASSERT_HOST(best_choice != nullptr);
mean_certainty += best_choice->certainty();
++certainty_count;
res_it.forward();
} while (res_it.row() == res_it.prev_row());
break;
case RIL_WORD:
mean_certainty += best_choice->certainty();
++certainty_count;
best_choice = res_it.word()->best_choice;
mean_certainty = best_choice->certainty();
certainty_count = 1;
break;
case RIL_SYMBOL:
mean_certainty += best_choice->certainty(blob_index_);
++certainty_count;
best_choice = res_it.word()->best_choice;
mean_certainty = best_choice->certainty(blob_index_);
certainty_count = 1;
}
if (certainty_count > 0) {
mean_certainty /= certainty_count;
Expand Down Expand Up @@ -320,7 +318,6 @@ char *LTRResultIterator::WordNormedUTF8Text() const {
std::string ocr_text;
WERD_CHOICE *best_choice = it_->word()->best_choice;
const UNICHARSET *unicharset = it_->word()->uch_set;
ASSERT_HOST(best_choice != nullptr);
for (unsigned i = 0; i < best_choice->length(); ++i) {
ocr_text += unicharset->get_normed_unichar(best_choice->unichar_id(i));
}
Expand Down

0 comments on commit 1b22245

Please sign in to comment.