diff --git a/src/ccmain/tessedit.cpp b/src/ccmain/tessedit.cpp index b7566611..019e7ae3 100644 --- a/src/ccmain/tessedit.cpp +++ b/src/ccmain/tessedit.cpp @@ -412,7 +412,7 @@ static void CollectFonts(const UnicityTable &new_fonts, // Helper assigns an id to lang_fonts using the index in all_fonts table. static void AssignIds(const UnicityTable &all_fonts, UnicityTable *lang_fonts) { for (int i = 0; i < lang_fonts->size(); ++i) { - int index = all_fonts.get_id(lang_fonts->at(i)); + auto index = all_fonts.get_index(lang_fonts->at(i)); lang_fonts->at(i).universal_id = index; } } diff --git a/src/ccutil/unicity_table.h b/src/ccutil/unicity_table.h index b12511df..fb8fbcce 100644 --- a/src/ccutil/unicity_table.h +++ b/src/ccutil/unicity_table.h @@ -59,7 +59,9 @@ public: /// Return the id of the T object. /// This method NEEDS a compare_callback to be passed to /// set_compare_callback. - int get_id(T object) const; + int get_index(T object) const { + return table_.get_index(object); + } /// Return true if T is in the table bool contains(T object) const; @@ -124,22 +126,16 @@ T UnicityTable::contains_id(int id) const { return table_.contains_index(id); } -// Return the id of the T object. -template -int UnicityTable::get_id(T object) const { - return table_.get_index(object); -} - // Return true if T is in the table template bool UnicityTable::contains(T object) const { - return get_id(object) != -1; + return get_index(object) != -1; } // Add an element in the table template int UnicityTable::push_back(T object) { - int idx = get_id(object); + auto idx = get_index(object); if (idx == -1) { table_.push_back(object); idx = size(); diff --git a/src/classify/adaptmatch.cpp b/src/classify/adaptmatch.cpp index 080092d0..07712ffb 100644 --- a/src/classify/adaptmatch.cpp +++ b/src/classify/adaptmatch.cpp @@ -421,7 +421,7 @@ void Classify::LearnPieces(const char *fontname, int start, int length, float th LearnBlob(fontname, rotated_blob, cn_denorm, fx_info, correct_text); } else if (unicharset.contains_unichar(correct_text)) { UNICHAR_ID class_id = unicharset.unichar_to_id(correct_text); - int font_id = word->fontinfo != nullptr ? fontinfo_table_.get_id(*word->fontinfo) : 0; + int font_id = word->fontinfo != nullptr ? fontinfo_table_.get_index(*word->fontinfo) : 0; if (classify_learning_debug_level >= 1) { tprintf("Adapting to char = %s, thr= %g font_id= %d\n", unicharset.id_to_unichar(class_id), threshold, font_id); diff --git a/src/classify/intproto.cpp b/src/classify/intproto.cpp index 33e53962..9c5850c0 100644 --- a/src/classify/intproto.cpp +++ b/src/classify/intproto.cpp @@ -511,7 +511,7 @@ INT_TEMPLATES_STRUCT *Classify::CreateIntTemplates(CLASSES FloatProtos, fs[i] = FClass->font_set.at(i); } if (this->fontset_table_.contains(fs)) { - IClass->font_set_id = this->fontset_table_.get_id(fs); + IClass->font_set_id = this->fontset_table_.get_index(fs); } else { IClass->font_set_id = this->fontset_table_.push_back(fs); }