From 929101a3afe56ff3af671caef3f03784ea3d0fe8 Mon Sep 17 00:00:00 2001 From: Harpreet Sangar Date: Wed, 22 Mar 2023 10:46:01 +0530 Subject: [PATCH] Refactor `filter_result_iterator_t::next()`. --- src/filter.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/filter.cpp b/src/filter.cpp index e7a46093..2c289761 100644 --- a/src/filter.cpp +++ b/src/filter.cpp @@ -190,19 +190,14 @@ void filter_result_iterator_t::next() { field f = index->search_schema.at(a_filter.field_name); if (f.is_string()) { - // Advance all the filter values that are at doc. Then find the next one. - std::vector doc_matching_indexes; + // Advance all the filter values that are at doc. Then find the next doc. for (uint32_t i = 0; i < posting_list_iterators.size(); i++) { - const auto& filter_value_tokens = posting_list_iterators[i]; + auto& filter_value_tokens = posting_list_iterators[i]; if (filter_value_tokens[0].valid() && filter_value_tokens[0].id() == doc) { - doc_matching_indexes.push_back(i); - } - } - - for (const auto &lowest_id_index: doc_matching_indexes) { - for (auto &iter: posting_list_iterators[lowest_id_index]) { - iter.next(); + for (auto& iter: filter_value_tokens) { + iter.next(); + } } } @@ -363,7 +358,7 @@ bool filter_result_iterator_t::valid() { return is_valid; } - return true; + return false; } void filter_result_iterator_t::skip_to(uint32_t id) {