Minor typing optimizations
This commit is contained in:
parent
5f866d9844
commit
913d9e0c46
3 changed files with 8 additions and 8 deletions
|
|
@ -17,7 +17,7 @@ pub fn inflate(data: &[u8]) -> Result<Vec<u8>, String> {
|
||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deflate(data: &[u8], zc: u8, zm: u8, zs: u8, zw: u16) -> Result<Vec<u8>, String> {
|
pub fn deflate(data: &[u8], zc: u8, zm: u8, zs: u8, zw: u8) -> Result<Vec<u8>, String> {
|
||||||
let mut input = data.to_owned();
|
let mut input = data.to_owned();
|
||||||
let mut stream = super::stream::Stream::new_compress(zc as libc::c_int,
|
let mut stream = super::stream::Stream::new_compress(zc as libc::c_int,
|
||||||
zw as libc::c_int,
|
zw as libc::c_int,
|
||||||
|
|
|
||||||
|
|
@ -62,19 +62,19 @@ impl Stream<Compress> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Direction> Stream<T> {
|
impl<T: Direction> Stream<T> {
|
||||||
pub fn total_in(&self) -> u64 {
|
pub fn total_in(&self) -> usize {
|
||||||
self.raw.total_in as u64
|
self.raw.total_in as usize
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn total_out(&self) -> u64 {
|
pub fn total_out(&self) -> usize {
|
||||||
self.raw.total_out as u64
|
self.raw.total_out as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stream<Decompress> {
|
impl Stream<Decompress> {
|
||||||
pub fn decompress_vec(&mut self, input: &mut [u8], output: &mut Vec<u8>) -> c_int {
|
pub fn decompress_vec(&mut self, input: &mut [u8], output: &mut Vec<u8>) -> c_int {
|
||||||
self.raw.avail_in = (input.len() - self.total_in() as usize) as c_uint;
|
self.raw.avail_in = (input.len() - self.total_in()) as c_uint;
|
||||||
self.raw.avail_out = (output.capacity() - self.total_out() as usize) as c_uint;
|
self.raw.avail_out = (output.capacity() - self.total_out()) as c_uint;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
self.raw.next_in = input.as_mut_ptr().offset(self.total_in() as isize);
|
self.raw.next_in = input.as_mut_ptr().offset(self.total_in() as isize);
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ pub struct Options {
|
||||||
pub compression: HashSet<u8>,
|
pub compression: HashSet<u8>,
|
||||||
pub memory: HashSet<u8>,
|
pub memory: HashSet<u8>,
|
||||||
pub strategies: HashSet<u8>,
|
pub strategies: HashSet<u8>,
|
||||||
pub window: u16,
|
pub window: u8,
|
||||||
pub bit_depth_reduction: bool,
|
pub bit_depth_reduction: bool,
|
||||||
pub color_type_reduction: bool,
|
pub color_type_reduction: bool,
|
||||||
pub palette_reduction: bool,
|
pub palette_reduction: bool,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue