nmslib / hnswlib

Header-only C++/python library for fast approximate nearest neighbors
https://github.com/nmslib/hnswlib
Apache License 2.0
4.12k stars 609 forks source link

Simplify VisitedList. #470

Closed ttsugriy closed 1 year ago

ttsugriy commented 1 year ago

It's error-prone to use raw pointers instead of std::unique_ptr which has no extra overhead compared to raw pointer but is easier to use. Also, it's better to use member initializer instead of constructor body.

yurymalkov commented 1 year ago

Hi @ttsugriy , thank you for the pull request! It looks like it causes some errors in the CI. Can you please look at it? I also wonder if you tested that it does not affect the performance?

ttsugriy commented 1 year ago

Hello, Yury! Unfortunately it looks like there are many callsites that use explicit pointer type instead of auto, so many more changes are required to migrate to unique_ptr. As for performance, this change doesn't affect it, since member initialization change involves only primitive types and unique_ptr is identical to raw pointer in the assembly.

yurymalkov commented 1 year ago

Got it, thanks!

ttsugriy commented 1 year ago

Thank you, @yurymalkov! I'm a huge fan of HNSW, so thank you very much for inventing it!

yurymalkov commented 1 year ago

@ttsugriy Thank you for the kind words! A lot of the hnswlib's value came from external PR contributions! :)