From 30ba55a382539f5629de387af87545b23538a3fa Mon Sep 17 00:00:00 2001 From: angie Date: Tue, 5 Dec 2023 12:35:22 -0300 Subject: [PATCH] cleanup --- src/yaz0.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/yaz0.rs b/src/yaz0.rs index 74423f2..ba2d001 100644 --- a/src/yaz0.rs +++ b/src/yaz0.rs @@ -75,17 +75,13 @@ pub fn compress_yaz0(bytes: &[u8]) -> Box<[u8]> { Vec::with_capacity(input_size + divide_round_up(input_size, 8) + 0x10); output.extend(b"Yaz0"); - //output.extend(index_out_ptr.to_be_bytes()); - //output.extend(&[0, 0, 0, 0]); output.extend((input_size as u32).to_be_bytes()); // padding output.extend(&[0, 0, 0, 0, 0, 0, 0, 0]); output.push(0); let mut index_cur_layout_byte: usize = 0x10; - //uint8_t* cur_layout_byte = &output[0]; let mut index_out_ptr: usize = index_cur_layout_byte + 1; - //uint8_t* out_ptr = cur_layout_byte + 1; let mut input_pos: usize = 0; let mut cur_layout_bit: u8 = 0x80; @@ -105,8 +101,6 @@ pub fn compress_yaz0(bytes: &[u8]) -> Box<[u8]> { if group_size <= 2 { // Set the current layout bit to indicate that this is an uncompressed byte output[index_cur_layout_byte] |= cur_layout_bit; - //*out_ptr++ = src[input_pos++]; - //output[index_out_ptr] = bytes[input_pos]; output.push(bytes[input_pos]); input_pos += 1; index_out_ptr += 1; @@ -128,8 +122,6 @@ pub fn compress_yaz0(bytes: &[u8]) -> Box<[u8]> { // Mark the current layout bit to skip compressing this byte, as the next input position yielded better compression output[index_cur_layout_byte] |= cur_layout_bit; // Copy the input byte to the output - //*out_ptr++ = src[input_pos++]; - // output[index_out_ptr] = bytes[input_pos]; output.push(bytes[input_pos]); input_pos += 1; index_out_ptr += 1; @@ -139,7 +131,6 @@ pub fn compress_yaz0(bytes: &[u8]) -> Box<[u8]> { if cur_layout_bit == 0 { cur_layout_bit = 0x80; - //cur_layout_byte = out_ptr++; index_cur_layout_byte = index_out_ptr; index_out_ptr += 1; output[index_cur_layout_byte] = 0; @@ -155,21 +146,16 @@ pub fn compress_yaz0(bytes: &[u8]) -> Box<[u8]> { // Determine which encoding to use for the current group if group_size >= 0x12 { // Three bytes, 0RRRNN - // output[index_out_ptr] = (group_offset >> 8) as u8; output.push((group_offset >> 8) as u8); index_out_ptr += 1; - // output[index_out_ptr] = (group_offset & 0xFF) as u8; output.push((group_offset & 0xFF) as u8); index_out_ptr += 1; - // output[index_out_ptr] = (group_size - 0x12) as u8; output.push((group_size - 0x12) as u8); index_out_ptr += 1; } else { // Two bytes, NRRR - // output[index_out_ptr] = (group_offset >> 8) as u8 | ((group_size - 2) << 4) as u8; output.push((group_offset >> 8) as u8 | ((group_size - 2) << 4) as u8); index_out_ptr += 1; - // output[index_out_ptr] = (group_offset & 0xFF) as u8; output.push((group_offset & 0xFF) as u8); index_out_ptr += 1; } @@ -183,7 +169,6 @@ pub fn compress_yaz0(bytes: &[u8]) -> Box<[u8]> { if cur_layout_bit == 0 { cur_layout_bit = 0x80; - //cur_layout_byte = out_ptr++; index_cur_layout_byte = index_out_ptr; output.push(0); index_out_ptr += 1;