From c84448eee1ed4df5b582624d4711b23352172a0e Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sun, 28 Jul 2024 20:46:49 +0200 Subject: [PATCH] Remove unnecessary assignment and assertions Signed-off-by: Stefan Weil --- src/ccmain/ltrresultiterator.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/ccmain/ltrresultiterator.cpp b/src/ccmain/ltrresultiterator.cpp index 4ff498fa37..84ed913a2f 100644 --- a/src/ccmain/ltrresultiterator.cpp +++ b/src/ccmain/ltrresultiterator.cpp @@ -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(); @@ -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(); @@ -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; @@ -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)); }