Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare variables prior to for loop in fastss.pyx for ANSI C compatibility #3378

Merged
merged 2 commits into from
Aug 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions gensim/similarities/fastss.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ cdef extern from *:
void * s1_data = PyUnicode_DATA(s1);
void * s2_data = PyUnicode_DATA(s2);

for (WIDTH tmpi = 0; tmpi <= len_s1; tmpi++) row2[tmpi] = tmpi;
WIDTH tmpi;
for (tmpi = 0; tmpi <= len_s1; tmpi++) row2[tmpi] = tmpi;

for (WIDTH i2 = 0; i2 < len_s2; i2++) {
WIDTH i2;
for (i2 = 0; i2 < len_s2; i2++) {
int all_bad = i2 >= maximum;
const Py_UCS4 ch = PyUnicode_READ(kind2, s2_data, i2);
row_flip = 1 - row_flip;
Expand All @@ -56,7 +58,8 @@ cdef extern from *:
}
*pos_new = i2 + 1;

for (WIDTH i1 = 0; i1 < len_s1; i1++) {
WIDTH i1;
for (i1 = 0; i1 < len_s1; i1++) {
WIDTH val = *(pos_old++);
if (ch != PyUnicode_READ(kind1, s1_data, i1)) {
const WIDTH _val1 = *pos_old;
Expand Down