Skip to content

Commit

Permalink
Fix shadowed variable in faiss/impl/simd_result_handlers.h
Browse files Browse the repository at this point in the history
Summary:
Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so.

This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug.

**What's a shadowed variable?**

Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs.

This diff fixes such an issue by renaming the variable.

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

Reviewed By: dmm-fb

Differential Revision: D52582819

fbshipit-source-id: 34c4d5eca31bcc2df5872c9eb3a286335c8ae131
  • Loading branch information
r-barnes authored and facebook-github-bot committed Jan 8, 2024
1 parent beef610 commit db09984
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions faiss/impl/simd_result_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ struct StoreResultHandler {
d1.store(data + ofs + 16);
}

void set_block_origin(size_t i0, size_t j0) {
this->i0 = i0;
this->j0 = j0;
void set_block_origin(size_t i0_2, size_t j0_2) {
this->i0 = i0_2;
this->j0 = j0_2;
}
};

Expand All @@ -78,8 +78,8 @@ struct FixedStorageHandler {
dis[q + i0][2 * b + 1] = d1;
}

void set_block_origin(size_t i0, size_t j0) {
this->i0 = i0;
void set_block_origin(size_t i0_2, size_t j0) {
this->i0 = i0_2;
assert(j0 == 0);
}

Expand Down Expand Up @@ -112,9 +112,9 @@ struct SIMDResultHandler {
explicit SIMDResultHandler(size_t ntotal)
: ntotal(ntotal), id_map(nullptr), q_map(nullptr), dbias(nullptr) {}

void set_block_origin(size_t i0, size_t j0) {
this->i0 = i0;
this->j0 = j0;
void set_block_origin(size_t i0_2, size_t j0_2) {
this->i0 = i0_2;
this->j0 = j0_2;
}

// adjust handler data for IVF.
Expand Down

0 comments on commit db09984

Please sign in to comment.