From 130b8a1c1e8a9e80bb5a4ecacc26d8f2861c392f Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 11 Jun 2024 19:00:17 +0200 Subject: [PATCH] Remove unused variable assignments This fixes some issues which were reported by Codacy. Signed-off-by: Stefan Weil --- src/arch/intsimdmatrixavx2.cpp | 1 - src/ccmain/fixspace.cpp | 3 +-- src/classify/intmatcher.cpp | 12 ++++-------- src/dict/dict.cpp | 2 +- src/textord/tablefind.cpp | 6 ++---- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/arch/intsimdmatrixavx2.cpp b/src/arch/intsimdmatrixavx2.cpp index 5e5a3e04ce..081490851c 100644 --- a/src/arch/intsimdmatrixavx2.cpp +++ b/src/arch/intsimdmatrixavx2.cpp @@ -568,7 +568,6 @@ static void matrixDotVector(int dim1, int dim2, const int8_t *wi, const double * output += group_size; } group_size /= 2; - w_step /= 2; if (output + group_size <= rounded_num_out) { PartialMatrixDotVector8(wi, scales, u, rounded_num_in, v); diff --git a/src/ccmain/fixspace.cpp b/src/ccmain/fixspace.cpp index 7f1b166dfc..7f03ff03ea 100644 --- a/src/ccmain/fixspace.cpp +++ b/src/ccmain/fixspace.cpp @@ -267,8 +267,6 @@ int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) { bool prev_char_1 = false; // prev ch a "1/I/l"? bool prev_char_digit = false; // prev ch 2..9 or 0 const char *punct_chars = "!\"`',.:;"; - bool prev_char_punct = false; - do { // current word WERD_RES *word = word_res_it.data(); @@ -325,6 +323,7 @@ int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) { /* Add 1 to total score for every joined punctuation regardless of context and rejtn */ if (tessedit_prefer_joined_punct) { + bool prev_char_punct; for (i = 0, offset = 0, prev_char_punct = false; i < word_len; offset += word->best_choice->unichar_lengths()[i++]) { bool current_char_punct = diff --git a/src/classify/intmatcher.cpp b/src/classify/intmatcher.cpp index 98162cdd2e..d32aee57de 100644 --- a/src/classify/intmatcher.cpp +++ b/src/classify/intmatcher.cpp @@ -892,7 +892,6 @@ void IntegerMatcher::DebugFeatureProtoError(INT_CLASS_STRUCT *ClassTemplate, BIT uint16_t ProtoNum; uint8_t ProtoWordNum; PROTO_SET_STRUCT *ProtoSet; - uint16_t ActualProtoNum; if (PrintMatchSummaryOn(Debug)) { tprintf("Configuration Mask:\n"); @@ -912,9 +911,8 @@ void IntegerMatcher::DebugFeatureProtoError(INT_CLASS_STRUCT *ClassTemplate, BIT if (PrintMatchSummaryOn(Debug)) { tprintf("Proto Mask:\n"); for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets; ProtoSetIndex++) { - ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET); for (ProtoWordNum = 0; ProtoWordNum < 2; ProtoWordNum++, ProtoMask++) { - ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET); + uint16_t ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET); for (ProtoNum = 0; ((ProtoNum < (PROTOS_PER_PROTO_SET >> 1)) && (ActualProtoNum < ClassTemplate->NumProtos)); ProtoNum++, ActualProtoNum++) { @@ -934,7 +932,7 @@ void IntegerMatcher::DebugFeatureProtoError(INT_CLASS_STRUCT *ClassTemplate, BIT tprintf("Proto Evidence:\n"); for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets; ProtoSetIndex++) { ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex]; - ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET); + uint16_t ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET); for (ProtoNum = 0; ((ProtoNum < PROTOS_PER_PROTO_SET) && (ActualProtoNum < ClassTemplate->NumProtos)); ProtoNum++, ActualProtoNum++) { @@ -991,7 +989,6 @@ void IntegerMatcher::DisplayProtoDebugInfo(INT_CLASS_STRUCT *ClassTemplate, BIT_ const ScratchEvidence &tables, bool SeparateDebugWindows) { uint16_t ProtoNum; - uint16_t ActualProtoNum; PROTO_SET_STRUCT *ProtoSet; int ProtoSetIndex; @@ -1003,7 +1000,7 @@ void IntegerMatcher::DisplayProtoDebugInfo(INT_CLASS_STRUCT *ClassTemplate, BIT_ for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets; ProtoSetIndex++) { ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex]; - ActualProtoNum = ProtoSetIndex * PROTOS_PER_PROTO_SET; + uint16_t ActualProtoNum = ProtoSetIndex * PROTOS_PER_PROTO_SET; for (ProtoNum = 0; ((ProtoNum < PROTOS_PER_PROTO_SET) && (ActualProtoNum < ClassTemplate->NumProtos)); ProtoNum++, ActualProtoNum++) { @@ -1076,13 +1073,12 @@ void ScratchEvidence::UpdateSumOfProtoEvidences(INT_CLASS_STRUCT *ClassTemplate, uint16_t ProtoNum; PROTO_SET_STRUCT *ProtoSet; int NumProtos; - uint16_t ActualProtoNum; NumProtos = ClassTemplate->NumProtos; for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets; ProtoSetIndex++) { ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex]; - ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET); + uint16_t ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET); for (ProtoNum = 0; ((ProtoNum < PROTOS_PER_PROTO_SET) && (ActualProtoNum < NumProtos)); ProtoNum++, ActualProtoNum++) { int temp = 0; diff --git a/src/dict/dict.cpp b/src/dict/dict.cpp index 8874a55ea6..be3cc1372f 100644 --- a/src/dict/dict.cpp +++ b/src/dict/dict.cpp @@ -886,7 +886,7 @@ bool Dict::valid_punctuation(const WERD_CHOICE &word) { } WERD_CHOICE new_word(word.unicharset()); auto last_index = word.length() - 1; - int new_len = 0; + int new_len; for (unsigned i = 0; i <= last_index; ++i) { UNICHAR_ID unichar_id = (word.unichar_id(i)); if (getUnicharset().get_ispunctuation(unichar_id)) { diff --git a/src/textord/tablefind.cpp b/src/textord/tablefind.cpp index 2ed4e495e7..537bec9cb0 100644 --- a/src/textord/tablefind.cpp +++ b/src/textord/tablefind.cpp @@ -884,8 +884,6 @@ bool TableFinder::HasWideOrNoInterWordGap(ColPartition *part) const { } // Variables used to compute inter-blob spacing. - int current_x0 = -1; - int current_x1 = -1; int previous_x1 = -1; // Stores the maximum gap detected. int largest_partition_gap_found = -1; @@ -897,8 +895,8 @@ bool TableFinder::HasWideOrNoInterWordGap(ColPartition *part) const { for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) { BLOBNBOX *blob = it.data(); - current_x0 = blob->bounding_box().left(); - current_x1 = blob->bounding_box().right(); + int current_x0 = blob->bounding_box().left(); + int current_x1 = blob->bounding_box().right(); if (previous_x1 != -1) { int gap = current_x0 - previous_x1;