From 2ee18cf284edfcc208267b38f815b32e651bc4fc Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 29 Feb 2024 12:20:21 +0000 Subject: c++11 for loops --- .../searchcore/proton/matching/docsum_matcher.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'searchcore/src') diff --git a/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp index 05a517a76b6..8d646597729 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp @@ -4,8 +4,6 @@ #include "match_tools.h" #include "search_session.h" #include "extract_features.h" -#include -#include #include #include #include @@ -63,10 +61,10 @@ void find_matching_elements(const std::vector &docs, const SameElement auto search = same_element.create_same_element_search(dummy_tfmd, false); search->initRange(docs.front(), docs.back()+1); std::vector matches; - for (uint32_t i = 0; i < docs.size(); ++i) { - search->find_matching_elements(docs[i], matches); + for (uint32_t doc : docs) { + search->find_matching_elements(doc, matches); if (!matches.empty()) { - result.add_matching_elements(docs[i], same_element.field_name(), matches); + result.add_matching_elements(doc, same_element.field_name(), matches); matches.clear(); } } @@ -74,20 +72,20 @@ void find_matching_elements(const std::vector &docs, const SameElement void find_matching_elements(const std::vector &docs, MatchingElementsSearch &search, MatchingElements &result) { search.initRange(docs.front(), docs.back() + 1); - for (uint32_t i = 0; i < docs.size(); ++i) { - search.find_matching_elements(docs[i], result); + for (uint32_t doc : docs) { + search.find_matching_elements(doc, result); } } void find_matching_elements(const std::vector &docs, const vespalib::string &field_name, const AttrSearchCtx &attr_ctx, MatchingElements &result) { int32_t weight = 0; std::vector matches; - for (uint32_t i = 0; i < docs.size(); ++i) { - for (int32_t id = attr_ctx.find(docs[i], 0, weight); id >= 0; id = attr_ctx.find(docs[i], id+1, weight)) { + for (uint32_t doc : docs) { + for (int32_t id = attr_ctx.find(doc, 0, weight); id >= 0; id = attr_ctx.find(doc, id+1, weight)) { matches.push_back(id); } if (!matches.empty()) { - result.add_matching_elements(docs[i], field_name, matches); + result.add_matching_elements(doc, field_name, matches); matches.clear(); } } -- cgit v1.2.3