[pdq] Replace POSIX dependent functions with STL equivalent #1333
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
While I was testing vpdq on Windows I had to make a couple changes to get it to build with pdq.
They're solid changes in general, so I thought I would upload them.
Use C++11 STL over OS dependent functions in general:
pdqhamming.h
which chooses either a lookup table or __builtin_popcount based on theUSE_BUILTIN_POPCOUNT
directive but some functions were directly calling __builtin_popcount regardless.None of these changes should affect bindings. The Python binding doesn't call any of the changed functions since they're almost all file IO.
I'm not sure why __builtin_popcount is being used at all. std::bitset::count and __builtin_popcount generate the same assembly. I can replace __builtin_popcount with std::bitset::count if you would like.
The getline problem is a really good example of why it's not good to do
using namespace std;
since std::getline and getline are both functions.I vaguely remember reading something about Buck for building and if you guys use that for PDQ I'm not sure how these changes would be affected by that.
Test Plan
Run included PDQ tests and vPDQ tests.