Remove unused variables in faiss/tests/test_threaded_index.cpp

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
pull/3253/head
Richard Barnes 2024-02-14 15:59:23 -08:00 committed by Facebook GitHub Bot
parent aaca1c2471
commit 53fc6171a6
1 changed files with 1 additions and 3 deletions

View File

@ -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);
@ -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);