Skip to content

Commit 7af604a

Browse files
committed
fix: define a new i to prevent type issues
rename j to jj
1 parent 80b76ac commit 7af604a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/matcher.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ std::vector<size_t> computeMatch(const CandidateString &subject, const Candidate
4343
auto trace = std::vector<Direction>(subject_size * query_size, Direction::STOP);
4444
auto pos = -1;
4545

46-
int i = 0;// TODO making it size_t breaks the code!
46+
auto i = 0u;
4747
while (i < subject_size) {//foreach char is of subject
4848
assert(0 <= i && i < subject_lw.size());
4949
Score score = 0;
@@ -112,26 +112,26 @@ std::vector<size_t> computeMatch(const CandidateString &subject, const Candidate
112112
// Go back in the trace matrix
113113
// and collect matches (diagonals)
114114

115-
i = subject_size - 1;
116-
auto j = query_size - 1;
117-
pos = i * query_size + j;
115+
int ii = subject_size - 1;
116+
auto jj = query_size - 1;
117+
pos = ii * query_size + jj;
118118
auto backtrack = true;
119119
std::vector<size_t> matches;
120120

121-
while (backtrack && i >= 0 && j >= 0) {
121+
while (backtrack && ii >= 0 && jj >= 0) {
122122
switch (trace[pos]) {
123123
case Direction::UP:
124-
i--;
124+
ii--;
125125
pos -= query_size;
126126
break;
127127
case Direction::LEFT:
128-
j--;
128+
jj--;
129129
pos--;
130130
break;
131131
case Direction::DIAGONAL:
132-
matches.emplace_back(i + offset);
133-
j--;
134-
i--;
132+
matches.emplace_back(ii + offset);
133+
jj--;
134+
ii--;
135135
pos -= query_size + 1;
136136
break;
137137
default:

0 commit comments

Comments
 (0)