Skip to content

Commit b977d25

Browse files
authored
Merge pull request #472 from ttsugriy/emplace
Replace priority_queue::push with emplace.
2 parents 643e9dc + 3ca227a commit b977d25

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hnswlib/bruteforce.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class BruteforceSearch : public AlgorithmInterface<dist_t> {
106106
dist_t dist = fstdistfunc_(query_data, data_ + size_per_element_ * i, dist_func_param_);
107107
labeltype label = *((labeltype*) (data_ + size_per_element_ * i + data_size_));
108108
if ((!isIdAllowed) || (*isIdAllowed)(label)) {
109-
topResults.push(std::pair<dist_t, labeltype>(dist, label));
109+
topResults.emplace(dist, label);
110110
}
111111
}
112112
dist_t lastdist = topResults.empty() ? std::numeric_limits<dist_t>::max() : topResults.top().first;
@@ -115,7 +115,7 @@ class BruteforceSearch : public AlgorithmInterface<dist_t> {
115115
if (dist <= lastdist) {
116116
labeltype label = *((labeltype *) (data_ + size_per_element_ * i + data_size_));
117117
if ((!isIdAllowed) || (*isIdAllowed)(label)) {
118-
topResults.push(std::pair<dist_t, labeltype>(dist, label));
118+
topResults.emplace(dist, label);
119119
}
120120
if (topResults.size() > k)
121121
topResults.pop();

0 commit comments

Comments
 (0)