Skip to content

Commit 78529ac

Browse files
committed
zdict.rs: cleanup loops
1 parent f40291e commit 78529ac

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/dictBuilder/zdict.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,8 @@ unsafe fn ZDICT_analyzePos(
230230

231231
// exit if not found a minimum number of repetitions
232232
if end.wrapping_sub(start) < minRatio {
233-
let mut idx: u32 = 0;
234-
idx = start;
235-
while idx < end {
233+
for idx in start..end {
236234
doneMarks[suffix(idx as usize) as usize] = true;
237-
idx = idx.wrapping_add(1);
238235
}
239236
return solution;
240237
}
@@ -260,14 +257,11 @@ unsafe fn ZDICT_analyzePos(
260257
let mut currentChar = 0;
261258
let mut currentCount = 0u32;
262259
let mut currentID = refinedStart;
263-
let mut id: u32 = 0;
264260
let mut selectedCount = 0;
265261
let mut selectedID = currentID;
266-
id = refinedStart;
267-
while id < refinedEnd {
268-
if *b.offset((suffix(id as usize)).wrapping_add(mml) as isize) as core::ffi::c_int
269-
!= currentChar as core::ffi::c_int
270-
{
262+
263+
for id in refinedStart..refinedEnd {
264+
if *b.offset((suffix(id as usize)).wrapping_add(mml) as isize) != currentChar {
271265
if currentCount > selectedCount {
272266
selectedCount = currentCount;
273267
selectedID = currentID;
@@ -277,8 +271,8 @@ unsafe fn ZDICT_analyzePos(
277271
currentCount = 0;
278272
}
279273
currentCount = currentCount.wrapping_add(1);
280-
id = id.wrapping_add(1);
281274
}
275+
282276
if currentCount > selectedCount {
283277
selectedCount = currentCount;
284278
selectedID = currentID;

0 commit comments

Comments
 (0)