diff --git a/src/api/hocrrenderer.cpp b/src/api/hocrrenderer.cpp index 33928adbd3..6744a8780f 100644 --- a/src/api/hocrrenderer.cpp +++ b/src/api/hocrrenderer.cpp @@ -412,7 +412,7 @@ char *TessBaseAPI::GetHOCRText(ETEXT_DESC *monitor, int page_number) { << " id='" << "timestep" << page_id << "_" << wcnt << "_" << tcnt << "'>"; - for (auto conf : timestep) { + for (auto &&conf : timestep) { hocr_str << "\n &font_set) const { uint32_t properties = at(font_id).properties; - for (auto f : font_set) { + for (auto &&f : font_set) { if (at(f.fontinfo_id).properties == properties) { return true; } diff --git a/src/ccutil/serialis.h b/src/ccutil/serialis.h index c955937e75..d6e4a99646 100644 --- a/src/ccutil/serialis.h +++ b/src/ccutil/serialis.h @@ -157,7 +157,7 @@ class TESS_API TFile { return false; } else if constexpr (std::is_same::value) { // Serialize strings. - for (auto string : data) { + for (auto &&string : data) { if (!Serialize(string)) { return false; } diff --git a/src/classify/adaptmatch.cpp b/src/classify/adaptmatch.cpp index 271aac5e06..75394f4685 100644 --- a/src/classify/adaptmatch.cpp +++ b/src/classify/adaptmatch.cpp @@ -1079,7 +1079,7 @@ void Classify::MasterMatcher(INT_TEMPLATES_STRUCT *templates, int16_t num_featur int top = blob_box.top(); int bottom = blob_box.bottom(); UnicharRating int_result; - for (auto result : results) { + for (auto &&result : results) { CLASS_ID class_id = result.Class; BIT_VECTOR protos = classes != nullptr ? classes[class_id]->PermProtos : AllProtosOn; BIT_VECTOR configs = classes != nullptr ? classes[class_id]->PermConfigs : AllConfigsOn; diff --git a/src/classify/shapeclassifier.cpp b/src/classify/shapeclassifier.cpp index 11a6168e84..071663b0f3 100644 --- a/src/classify/shapeclassifier.cpp +++ b/src/classify/shapeclassifier.cpp @@ -174,7 +174,7 @@ void ShapeClassifier::UnicharPrintResults(const char *context, GetUnicharset().id_to_unichar(result.unichar_id)); if (!result.fonts.empty()) { tprintf(" Font Vector:"); - for (auto font : result.fonts) { + for (auto &&font : result.fonts) { tprintf(" %d", font.fontinfo_id); } } diff --git a/src/dict/dawg.h b/src/dict/dawg.h index 0869f68df4..e71d728120 100644 --- a/src/dict/dawg.h +++ b/src/dict/dawg.h @@ -382,7 +382,7 @@ class DawgPositionVector : public std::vector { /// true otherwise. inline bool add_unique(const DawgPosition &new_pos, bool debug, const char *debug_msg) { - for (auto position : *this) { + for (auto &&position : *this) { if (position == new_pos) { return false; } diff --git a/src/lstm/networkio.cpp b/src/lstm/networkio.cpp index a6e7d69a6c..3cb068c6d4 100644 --- a/src/lstm/networkio.cpp +++ b/src/lstm/networkio.cpp @@ -173,7 +173,7 @@ void NetworkIO::FromPixes(const StaticShape &shape, const std::vector &pi int target_height = shape.height(); int target_width = shape.width(); std::vector> h_w_pairs; - for (auto pix : pixes) { + for (auto &&pix : pixes) { Image var_pix = pix; int width = pixGetWidth(var_pix); if (target_width != 0) { diff --git a/src/lstm/recodebeam.cpp b/src/lstm/recodebeam.cpp index 4b00166fbf..2a8a0fcdca 100644 --- a/src/lstm/recodebeam.cpp +++ b/src/lstm/recodebeam.cpp @@ -341,7 +341,7 @@ void RecodeBeamSearch::PrintBeam2(bool uids, int num_outputs, // fill the topology with depths first for (int step = beam.size() - 1; step >= 0; --step) { std::vector &heaps = beam.at(step)->beams_->heap(); - for (auto node : heaps) { + for (auto &&node : heaps) { int backtracker = 0; const RecodeNode *curr = &node.data(); while (curr != nullptr && !visited.count(curr)) { @@ -426,7 +426,7 @@ void RecodeBeamSearch::extractSymbolChoices(const UNICHARSET *unicharset) { std::vector best_nodes; std::vector best; // Scan the segmented node chain for valid unichar ids. - for (auto entry : heaps) { + for (auto &&entry : heaps) { bool validChar = false; int backcounter = 0; const RecodeNode *node = &entry.data(); diff --git a/src/training/pango/pango_font_info.cpp b/src/training/pango/pango_font_info.cpp index 076f0badc4..5ad619e4ec 100644 --- a/src/training/pango/pango_font_info.cpp +++ b/src/training/pango/pango_font_info.cpp @@ -591,7 +591,7 @@ int FontUtils::FontScore(const std::unordered_map &ch_map, } *raw_score = 0; int ok_chars = 0; - for (auto it : ch_map) { + for (auto &&it : ch_map) { bool covered = (coverage != nullptr) && (IsWhitespace(it.first) || (pango_coverage_get(coverage, it.first) == PANGO_COVERAGE_EXACT)); diff --git a/src/wordrec/chopper.cpp b/src/wordrec/chopper.cpp index 030735f8c1..195af68ef6 100644 --- a/src/wordrec/chopper.cpp +++ b/src/wordrec/chopper.cpp @@ -283,7 +283,7 @@ SEAM *Wordrec::chop_overlapping_blob(const std::vector &boxes, bool italic bool almost_equal_box = false; int num_overlap = 0; - for (auto boxe : boxes) { + for (auto &&boxe : boxes) { if (original_box.overlap_fraction(boxe) > 0.125) { num_overlap++; } diff --git a/src/wordrec/lm_pain_points.cpp b/src/wordrec/lm_pain_points.cpp index 4320bcf08a..486525aecb 100644 --- a/src/wordrec/lm_pain_points.cpp +++ b/src/wordrec/lm_pain_points.cpp @@ -130,7 +130,7 @@ void LMPainPoints::GenerateFromAmbigs(const DANGERR &fixpt, ViterbiStateEntry *v WERD_RES *word_res) { // Begins and ends in DANGERR vector now record the blob indices as used // by the ratings matrix. - for (auto danger : fixpt) { + for (auto &&danger : fixpt) { // Only use dangerous ambiguities. if (danger.dangerous) { GeneratePainPoint(danger.begin, danger.end - 1, LM_PPTYPE_AMBIG, vse->cost, true, @@ -203,7 +203,7 @@ bool LMPainPoints::GeneratePainPoint(int col, int row, LMPainPointsType pp_type, void LMPainPoints::RemapForSplit(int index) { for (auto &pain_points_heap : pain_points_heaps_) { std::vector &heap = pain_points_heap.heap(); - for (auto entry : heap) { + for (auto &&entry : heap) { entry.data().MapForSplit(index); } }