Skip to content

Commit

Permalink
Remove unused variables in faiss/tests/test_threaded_index.cpp
Browse files Browse the repository at this point in the history
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: palmje

Differential Revision: D53779512

fbshipit-source-id: 038967a05306d921cc09f48ae71b4e6d4eda6664
  • Loading branch information
r-barnes authored and facebook-github-bot committed Feb 14, 2024
1 parent aaca1c2 commit 53fc617
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions tests/test_threaded_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ TEST(ThreadedIndex, TestReplica) {
int k = 6;

// Try with threading and without
for (bool threaded : {true, false}) {
for ([[maybe_unused]] const bool threaded : {true, false}) {
std::vector<std::unique_ptr<MockIndex>> idxs;
faiss::IndexReplicas replica(d);

Expand Down Expand Up @@ -247,8 +247,6 @@ TEST(ThreadedIndex, TestShards) {
shards.search(n, x.data(), k, distances.data(), labels.data());

for (int i = 0; i < idxs.size(); ++i) {
auto perShard = n / idxs.size();

EXPECT_EQ(idxs[i]->nCalled, n);
EXPECT_EQ(idxs[i]->xCalled, x.data());
EXPECT_EQ(idxs[i]->kCalled, k);
Expand Down

0 comments on commit 53fc617

Please sign in to comment.