Skip to content

Commit 727a6ec

Browse files
committed
stop using step_by in hot loop
see rust-lang/rust#141360 (comment)
1 parent 865a992 commit 727a6ec

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

zlib-rs/src/inflate/inftrees.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,16 @@ pub(crate) fn inflate_table(
159159

160160
// replicate for those indices with low len bits equal to huff
161161
let incr = 1 << (len - drop_);
162-
let min = 1 << curr; // also has the name 'fill' in the C code
162+
let mut fill = 1 << curr;
163+
let min = fill;
163164

164-
let base = &mut table[next + (huff >> drop_)..];
165-
for fill in (0..min).step_by(incr) {
166-
base[fill] = here;
165+
loop {
166+
fill -= incr;
167+
table[next + (huff >> drop_) + fill] = here;
168+
169+
if fill == 0 {
170+
break;
171+
}
167172
}
168173

169174
// backwards increment the len-bit code huff

0 commit comments

Comments
 (0)