Skip to content

Commit db09984

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix shadowed variable in faiss/impl/simd_result_handlers.h
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
1 parent beef610 commit db09984

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

faiss/impl/simd_result_handlers.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ struct StoreResultHandler {
6161
d1.store(data + ofs + 16);
6262
}
6363

64-
void set_block_origin(size_t i0, size_t j0) {
65-
this->i0 = i0;
66-
this->j0 = j0;
64+
void set_block_origin(size_t i0_2, size_t j0_2) {
65+
this->i0 = i0_2;
66+
this->j0 = j0_2;
6767
}
6868
};
6969

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

81-
void set_block_origin(size_t i0, size_t j0) {
82-
this->i0 = i0;
81+
void set_block_origin(size_t i0_2, size_t j0) {
82+
this->i0 = i0_2;
8383
assert(j0 == 0);
8484
}
8585

@@ -112,9 +112,9 @@ struct SIMDResultHandler {
112112
explicit SIMDResultHandler(size_t ntotal)
113113
: ntotal(ntotal), id_map(nullptr), q_map(nullptr), dbias(nullptr) {}
114114

115-
void set_block_origin(size_t i0, size_t j0) {
116-
this->i0 = i0;
117-
this->j0 = j0;
115+
void set_block_origin(size_t i0_2, size_t j0_2) {
116+
this->i0 = i0_2;
117+
this->j0 = j0_2;
118118
}
119119

120120
// adjust handler data for IVF.

0 commit comments

Comments
 (0)