Skip to content

Commit 9a63a3c

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix shadowed variable in faiss/IndexFastScan.cpp
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: meyering Differential Revision: D52582914 fbshipit-source-id: edb3983635de4343c4a0b20096e81852cfa058c6
1 parent 7dd06dd commit 9a63a3c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

faiss/IndexFastScan.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ inline size_t roundup(size_t a, size_t b) {
3737

3838
void IndexFastScan::init_fastscan(
3939
int d,
40-
size_t M,
41-
size_t nbits,
40+
size_t M_2,
41+
size_t nbits_2,
4242
MetricType metric,
4343
int bbs) {
44-
FAISS_THROW_IF_NOT(nbits == 4);
44+
FAISS_THROW_IF_NOT(nbits_2 == 4);
4545
FAISS_THROW_IF_NOT(bbs % 32 == 0);
4646
this->d = d;
47-
this->M = M;
48-
this->nbits = nbits;
47+
this->M = M_2;
48+
this->nbits = nbits_2;
4949
this->metric_type = metric;
5050
this->bbs = bbs;
51-
ksub = (1 << nbits);
51+
ksub = (1 << nbits_2);
5252

53-
code_size = (M * nbits + 7) / 8;
53+
code_size = (M_2 * nbits_2 + 7) / 8;
5454
ntotal = ntotal2 = 0;
55-
M2 = roundup(M, 2);
55+
M2 = roundup(M_2, 2);
5656
is_trained = false;
5757
}
5858

0 commit comments

Comments
 (0)