Skip to content

Commit 12637a2

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix shadowed variable in faiss/utils/utils.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: algoriddle Differential Revision: D52959071 fbshipit-source-id: c71b331f9a1ee214cfef8143fdd41c336284d8a2
1 parent 63edc32 commit 12637a2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

faiss/utils/utils.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,9 @@ int64_t count_gt(int64_t n, const T* row, T threshold) {
582582
} // namespace
583583

584584
template <typename T>
585-
void CombinerRangeKNN<T>::compute_sizes(int64_t* L_res) {
586-
this->L_res = L_res;
587-
L_res[0] = 0;
585+
void CombinerRangeKNN<T>::compute_sizes(int64_t* L_res_2) {
586+
this->L_res = L_res_2;
587+
L_res_2[0] = 0;
588588
int64_t j = 0;
589589
for (int64_t i = 0; i < nq; i++) {
590590
int64_t n_in;
@@ -595,11 +595,11 @@ void CombinerRangeKNN<T>::compute_sizes(int64_t* L_res) {
595595
n_in = lim_remain[j + 1] - lim_remain[j];
596596
j++;
597597
}
598-
L_res[i + 1] = n_in; // L_res[i] + n_in;
598+
L_res_2[i + 1] = n_in; // L_res_2[i] + n_in;
599599
}
600600
// cumsum
601601
for (int64_t i = 0; i < nq; i++) {
602-
L_res[i + 1] += L_res[i];
602+
L_res_2[i + 1] += L_res_2[i];
603603
}
604604
}
605605

0 commit comments

Comments
 (0)