Skip to content

Commit 487cf1b

Browse files
committed
fix: use const candidates_size
1 parent 5e732b4 commit 487cf1b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/filter.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,28 @@ std::vector<CandidateIndex> sort_priority_queue(CandidateScorePriorityQueue &&ca
6161

6262
std::vector<CandidateIndex> filter(const vector<std::vector<CandidateString>> &candidates, const Element &query, const Options &options) {
6363
const auto candidates_size = candidates.size();
64-
6564
assert(1 <= candidates_size);// TODO handled outside
6665

67-
CandidateScorePriorityQueue top_k;
6866
auto max_results = options.max_results;
6967
if (max_results == 0u) {
7068
max_results = std::numeric_limits<size_t>::max();
7169
}
7270

7371
// Split the dataset and pass down to multiple threads.
7472
vector<thread> threads;
75-
threads.reserve(candidates.size() - 1);// 1 less thread
73+
threads.reserve(candidates_size - 1);// 1 less thread
7674

77-
auto results = vector<CandidateScorePriorityQueue>(candidates.size());
75+
auto results = vector<CandidateScorePriorityQueue>(candidates_size);
7876

7977
size_t start_index = 0;
8078
for (size_t i = 1; i < candidates_size; i++) {
81-
assert(1 <= i && i < candidates.size() && i < results.size());
79+
assert(1 <= i && i < candidates_size && i < results.size());
8280
start_index += candidates[i - 1].size();//inbounds
8381
threads.emplace_back(filter_internal, ref(candidates[i]), start_index, ref(query), ref(options), max_results, ref(results[i]));// inbounds
8482
}
83+
assert(threads.size() == candidates_size - 1 && results.size() == candidates_size);
8584

86-
assert(threads.size() == candidates.size() - 1 && results.size() == candidates.size());
87-
85+
CandidateScorePriorityQueue top_k;
8886
// Do the work for first thread.
8987
filter_internal(candidates[0], 0, query, options, max_results, top_k);//inbounds (candidate_size >= 1)
9088
// Wait for threads to complete and merge the results.

0 commit comments

Comments
 (0)