From 3ca227ab2bce6f6cadc8e3b81905955c585190b8 Mon Sep 17 00:00:00 2001 From: Taras Tsugrii Date: Sun, 18 Jun 2023 20:39:51 -0500 Subject: [PATCH] Replace priority_queue::push with emplace. --- hnswlib/bruteforce.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hnswlib/bruteforce.h b/hnswlib/bruteforce.h index 30b33ae9..8a65c83f 100644 --- a/hnswlib/bruteforce.h +++ b/hnswlib/bruteforce.h @@ -106,7 +106,7 @@ class BruteforceSearch : public AlgorithmInterface { dist_t dist = fstdistfunc_(query_data, data_ + size_per_element_ * i, dist_func_param_); labeltype label = *((labeltype*) (data_ + size_per_element_ * i + data_size_)); if ((!isIdAllowed) || (*isIdAllowed)(label)) { - topResults.push(std::pair(dist, label)); + topResults.emplace(dist, label); } } dist_t lastdist = topResults.empty() ? std::numeric_limits::max() : topResults.top().first; @@ -115,7 +115,7 @@ class BruteforceSearch : public AlgorithmInterface { if (dist <= lastdist) { labeltype label = *((labeltype *) (data_ + size_per_element_ * i + data_size_)); if ((!isIdAllowed) || (*isIdAllowed)(label)) { - topResults.push(std::pair(dist, label)); + topResults.emplace(dist, label); } if (topResults.size() > k) topResults.pop();