Skip to content

Commit ab012ae

Browse files
authored
Merge pull request #233 from jwimberley/gcc_warning_fixes
GCC sign_compare and reorder warning flags patches
2 parents 40f31da + 4a4689c commit ab012ae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

hnswlib/hnswalg.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace hnswlib {
2727
}
2828

2929
HierarchicalNSW(SpaceInterface<dist_t> *s, size_t max_elements, size_t M = 16, size_t ef_construction = 200, size_t random_seed = 100) :
30-
link_list_locks_(max_elements), element_levels_(max_elements), link_list_update_locks_(max_update_element_locks) {
30+
link_list_locks_(max_elements), link_list_update_locks_(max_update_element_locks), element_levels_(max_elements) {
3131
max_elements_ = max_elements;
3232

3333
has_deletions_=false;
@@ -869,12 +869,12 @@ namespace hnswlib {
869869
// continue;
870870

871871
std::priority_queue<std::pair<dist_t, tableint>, std::vector<std::pair<dist_t, tableint>>, CompareByFirst> candidates;
872-
int size = sCand.find(neigh) == sCand.end() ? sCand.size() : sCand.size() - 1;
873-
int elementsToKeep = std::min(int(ef_construction_), size);
872+
size_t size = sCand.find(neigh) == sCand.end() ? sCand.size() : sCand.size() - 1; // sCand guaranteed to have size >= 1
873+
size_t elementsToKeep = std::min(ef_construction_, size);
874874
for (auto&& cand : sCand) {
875875
if (cand == neigh)
876876
continue;
877-
877+
878878
dist_t distance = fstdistfunc_(getDataByInternalId(neigh), getDataByInternalId(cand), dist_func_param_);
879879
if (candidates.size() < elementsToKeep) {
880880
candidates.emplace(distance, cand);
@@ -893,7 +893,7 @@ namespace hnswlib {
893893
std::unique_lock <std::mutex> lock(link_list_locks_[neigh]);
894894
linklistsizeint *ll_cur;
895895
ll_cur = get_linklist_at_level(neigh, layer);
896-
int candSize = candidates.size();
896+
size_t candSize = candidates.size();
897897
setListCount(ll_cur, candSize);
898898
tableint *data = (tableint *) (ll_cur + 1);
899899
for (size_t idx = 0; idx < candSize; idx++) {

0 commit comments

Comments
 (0)