From 553ab64d8dd2e11098bbc10f10532a75ac40fd43 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 26 Jul 2021 07:43:15 +0200 Subject: [PATCH] Rename UnicityTable::get_id to UnicityTable::get_index This prepares replacing UnicityTable by FontInfoTable. Signed-off-by: Stefan Weil --- src/ccmain/tessedit.cpp | 2 +- src/ccutil/unicity_table.h | 14 +++++--------- src/classify/adaptmatch.cpp | 2 +- src/classify/intproto.cpp | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) 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); }