diff --git a/src/ccmain/resultiterator.cpp b/src/ccmain/resultiterator.cpp index ca3c79c2..d8f537f2 100644 --- a/src/ccmain/resultiterator.cpp +++ b/src/ccmain/resultiterator.cpp @@ -257,7 +257,7 @@ void ResultIterator::CalculateTextlineOrder( std::vector dirs; std::vector* directions; directions = (dirs_arg != nullptr) ? dirs_arg : &dirs; - directions->resize(0); + directions->clear(); // A LTRResultIterator goes strictly left-to-right word order. LTRResultIterator ltr_it(resit); @@ -268,7 +268,7 @@ void ResultIterator::CalculateTextlineOrder( directions->push_back(ltr_it.WordDirection()); } while (ltr_it.Next(RIL_WORD) && !ltr_it.IsAtBeginningOf(RIL_TEXTLINE)); - word_indices->resize(0); + word_indices->clear(); CalculateTextlineOrder(paragraph_is_ltr, *directions, word_indices); } @@ -276,7 +276,7 @@ void ResultIterator::CalculateTextlineOrder( bool paragraph_is_ltr, const std::vector& word_dirs, std::vector* reading_order) { - reading_order->resize(0); + reading_order->clear(); if (word_dirs.size() == 0) return; diff --git a/src/ccutil/serialis.cpp b/src/ccutil/serialis.cpp index 895b5458..20f71769 100644 --- a/src/ccutil/serialis.cpp +++ b/src/ccutil/serialis.cpp @@ -212,7 +212,7 @@ void TFile::OpenWrite(std::vector* data) { } is_writing_ = true; swap_ = false; - data_->resize(0); + data_->clear(); } bool TFile::CloseWrite(const char* filename, FileWriter writer) { diff --git a/src/ccutil/unicharset.cpp b/src/ccutil/unicharset.cpp index 36c471f3..e0f57ad4 100644 --- a/src/ccutil/unicharset.cpp +++ b/src/ccutil/unicharset.cpp @@ -244,7 +244,7 @@ bool UNICHARSET::encode_string(const char* str, bool give_up_on_failure, std::vector working_encoding; std::vector working_lengths; std::vector best_lengths; - encoding->resize(0); // Just in case str is empty. + encoding->clear(); // Just in case str is empty. int str_length = strlen(str); int str_pos = 0; bool perfect = true; @@ -352,13 +352,13 @@ STRING UNICHARSET::debug_str(UNICHAR_ID id) const { // Sets the normed_ids vector from the normed string. normed_ids is not // stored in the file, and needs to be set when the UNICHARSET is loaded. void UNICHARSET::set_normed_ids(UNICHAR_ID unichar_id) { - unichars[unichar_id].properties.normed_ids.resize(0); + unichars[unichar_id].properties.normed_ids.clear(); if (unichar_id == UNICHAR_SPACE && id_to_unichar(unichar_id)[0] == ' ') { unichars[unichar_id].properties.normed_ids.push_back(UNICHAR_SPACE); } else if (!encode_string(unichars[unichar_id].properties.normed.c_str(), true, &unichars[unichar_id].properties.normed_ids, nullptr, nullptr)) { - unichars[unichar_id].properties.normed_ids.resize(0); + unichars[unichar_id].properties.normed_ids.clear(); unichars[unichar_id].properties.normed_ids.push_back(unichar_id); } } diff --git a/src/ccutil/unicharset.h b/src/ccutil/unicharset.h index 2629474a..de6b2ef2 100644 --- a/src/ccutil/unicharset.h +++ b/src/ccutil/unicharset.h @@ -467,7 +467,7 @@ class TESS_API UNICHARSET { // Record normalized version of unichar with the given unichar_id. void set_normed(UNICHAR_ID unichar_id, const char* normed) { unichars[unichar_id].properties.normed = normed; - unichars[unichar_id].properties.normed_ids.resize(0); + unichars[unichar_id].properties.normed_ids.clear(); } // Sets the normed_ids vector from the normed string. normed_ids is not // stored in the file, and needs to be set when the UNICHARSET is loaded. diff --git a/src/classify/adaptmatch.cpp b/src/classify/adaptmatch.cpp index 9895e0ef..65254b8a 100644 --- a/src/classify/adaptmatch.cpp +++ b/src/classify/adaptmatch.cpp @@ -1182,7 +1182,7 @@ void Classify::ExpandShapesAndApplyCorrections( if (r == mapped_results.size()) { mapped_results.push_back(*int_result); mapped_results[r].unichar_id = unichar_id; - mapped_results[r].fonts.resize(0); + mapped_results[r].fonts.clear(); } for (int i = 0; i < shape[c].font_ids.size(); ++i) { mapped_results[r].fonts.push_back( diff --git a/src/classify/intmatcher.cpp b/src/classify/intmatcher.cpp index e53b4aa2..eb1e3892 100644 --- a/src/classify/intmatcher.cpp +++ b/src/classify/intmatcher.cpp @@ -1190,7 +1190,7 @@ int IntegerMatcher::FindBestMatch( UnicharRating* result) { int best_match = 0; result->config = 0; - result->fonts.resize(0); + result->fonts.clear(); result->fonts.reserve(class_template->NumConfigs); /* Find best match */ diff --git a/src/classify/shapeclassifier.cpp b/src/classify/shapeclassifier.cpp index 3cb343d9..b1091a53 100644 --- a/src/classify/shapeclassifier.cpp +++ b/src/classify/shapeclassifier.cpp @@ -41,7 +41,7 @@ namespace tesseract { int ShapeClassifier::UnicharClassifySample( const TrainingSample& sample, Pix* page_pix, int debug, UNICHAR_ID keep_this, std::vector* results) { - results->resize(0); + results->clear(); std::vector shape_results; int num_shape_results = ClassifySample(sample, page_pix, debug, keep_this, &shape_results); diff --git a/src/lstm/lstmrecognizer.cpp b/src/lstm/lstmrecognizer.cpp index 6d60e8d8..18231829 100644 --- a/src/lstm/lstmrecognizer.cpp +++ b/src/lstm/lstmrecognizer.cpp @@ -488,8 +488,8 @@ void LSTMRecognizer::LabelsViaReEncode(const NetworkIO& output, void LSTMRecognizer::LabelsViaSimpleText(const NetworkIO& output, std::vector* labels, std::vector* xcoords) { - labels->resize(0); - xcoords->resize(0); + labels->clear(); + xcoords->clear(); const int width = output.Width(); for (int t = 0; t < width; ++t) { float score = 0.0f; diff --git a/src/lstm/recodebeam.cpp b/src/lstm/recodebeam.cpp index 779dc128..93a265ed 100644 --- a/src/lstm/recodebeam.cpp +++ b/src/lstm/recodebeam.cpp @@ -192,8 +192,8 @@ void RecodeBeamSearch::calculateCharBoundaries(std::vector* starts, // Returns the best path as labels/scores/xcoords similar to simple CTC. void RecodeBeamSearch::ExtractBestPathAsLabels( std::vector* labels, std::vector* xcoords) const { - labels->resize(0); - xcoords->resize(0); + labels->clear(); + xcoords->clear(); GenericVector best_nodes; ExtractBestPaths(&best_nodes, nullptr); // Now just run CTC on the best nodes. @@ -547,10 +547,10 @@ void RecodeBeamSearch::ExtractPathAsUnicharIds( std::vector* unichar_ids, std::vector* certs, std::vector* ratings, std::vector* xcoords, std::vector* character_boundaries) { - unichar_ids->resize(0); - certs->resize(0); - ratings->resize(0); - xcoords->resize(0); + unichar_ids->clear(); + certs->clear(); + ratings->clear(); + xcoords->clear(); std::vector starts; std::vector ends; // Backtrack extracting only valid, non-duplicate unichar-ids. diff --git a/src/training/pango/pango_font_info.cpp b/src/training/pango/pango_font_info.cpp index 86771b58..89b2cb3b 100644 --- a/src/training/pango/pango_font_info.cpp +++ b/src/training/pango/pango_font_info.cpp @@ -270,7 +270,7 @@ int PangoFontInfo::DropUncoveredChars(std::string* utf8_text) const { if (font == nullptr) { // Font not found, drop all characters. num_dropped_chars = utf8_text->length(); - utf8_text->resize(0); + utf8_text->clear(); return num_dropped_chars; } PangoCoverage* coverage = pango_font_get_coverage(font, nullptr); diff --git a/src/training/unicharset/lstmtrainer.cpp b/src/training/unicharset/lstmtrainer.cpp index 86b72004..aadabc07 100644 --- a/src/training/unicharset/lstmtrainer.cpp +++ b/src/training/unicharset/lstmtrainer.cpp @@ -694,7 +694,7 @@ bool LSTMTrainer::EncodeString(const STRING& str, const UNICHARSET& unicharset, } int err_index; std::vector internal_labels; - labels->resize(0); + labels->clear(); if (!simple_text) labels->push_back(null_char); std::string cleaned = unicharset.CleanupString(str.c_str()); if (unicharset.encode_string(cleaned.c_str(), true, &internal_labels, nullptr, diff --git a/src/training/unicharset_extractor.cpp b/src/training/unicharset_extractor.cpp index 9c77e798..c2c6d7b5 100644 --- a/src/training/unicharset_extractor.cpp +++ b/src/training/unicharset_extractor.cpp @@ -74,7 +74,7 @@ static int Main(int argc, char** argv) { tprintf("Extracting unicharset from box file %s\n", argv[arg]); } else { tprintf("Extracting unicharset from plain text file %s\n", argv[arg]); - texts.resize(0); + texts.clear(); file_data.split('\n', &texts); } AddStringsToUnicharset(texts, FLAGS_norm_mode, &unicharset);