Eliminate the recursive call
This commit is contained in:
parent
09ae98065c
commit
f997a6250c
|
@ -278,6 +278,7 @@ impl Encoder {
|
||||||
/// After reaching the end of the buffer we write a 0 byte. Only write 0 if the byte array is empty.
|
/// After reaching the end of the buffer we write a 0 byte. Only write 0 if the byte array is empty.
|
||||||
/// This is byte alignment agnostic.
|
/// This is byte alignment agnostic.
|
||||||
fn write_blk(&mut self, arr: &[u8], src_ptr: &mut usize) {
|
fn write_blk(&mut self, arr: &[u8], src_ptr: &mut usize) {
|
||||||
|
loop {
|
||||||
let src_len = arr.len() - *src_ptr;
|
let src_len = arr.len() - *src_ptr;
|
||||||
let blk_len = src_len.min(255);
|
let blk_len = src_len.min(255);
|
||||||
|
|
||||||
|
@ -290,7 +291,6 @@ impl Encoder {
|
||||||
self.buffer.extend(&arr[*src_ptr..blk_len]);
|
self.buffer.extend(&arr[*src_ptr..blk_len]);
|
||||||
|
|
||||||
*src_ptr += blk_len;
|
*src_ptr += blk_len;
|
||||||
|
}
|
||||||
self.write_blk(arr, src_ptr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue