fix large window sizes

png-branch
an 2019-03-12 05:52:31 -04:00
parent f832a45f36
commit 499c25fb93
2 changed files with 20 additions and 8 deletions

View File

@ -37,7 +37,18 @@ macro_rules! bail {
/// ///
/// assert_eq!(format!("{}", err_msg("oh no not things")), "oh no not things"); /// assert_eq!(format!("{}", err_msg("oh no not things")), "oh no not things");
/// ``` /// ```
pub fn err_msg(msg: &'static str) -> Error {Error::from(ErrMsg(msg))} pub fn err_msg(msg: &'static str) -> Error {ErrMsg(msg).into()}
/// Returns an `Error` from a `ReprError`.
///
/// # Examples
///
/// ```
/// use maraiah::durandal::err::repr_error;
///
/// assert_eq!(format!("{}", repr_error(77)), "representation error (got 77)");
/// ```
pub fn repr_error<T: Into<i64>>(n: T) -> Error {ReprError::new(n).into()}
impl ReprError impl ReprError
{ {
@ -53,7 +64,7 @@ impl ReprError
/// assert_eq!(format!("{}", err), "representation error (got 7)"); /// assert_eq!(format!("{}", err), "representation error (got 7)");
/// ``` /// ```
#[inline] #[inline]
pub fn new<T>(n: T) -> Self where T: Into<i64> {Self(n.into())} pub fn new<T: Into<i64>>(n: T) -> Self {Self(n.into())}
} }
impl Fail for ReprError {} impl Fail for ReprError {}

View File

@ -217,14 +217,15 @@ fn stream_dynamic(v: &mut Vec<u8>, b: &[u8], mut p: usize) -> ResultS<usize>
output_tables(v, b, p, table_len, table_dst) output_tables(v, b, p, table_len, table_dst)
} }
#[allow(clippy::needless_range_loop)]
fn stream_s_table(v: &mut Vec<u8>, b: &[u8], p: usize) -> ResultS<usize> fn stream_s_table(v: &mut Vec<u8>, b: &[u8], p: usize) -> ResultS<usize>
{ {
let mut len = [0; 288]; let mut len = [0; 288];
for len in len.iter_mut().take(144) {*len = 8;} for i in 0..144 {len[i] = 8;}
for len in len.iter_mut().take(256).skip(144) {*len = 9;} for i in 144..256 {len[i] = 9;}
for len in len.iter_mut().take(280).skip(256) {*len = 7;} for i in 256..280 {len[i] = 7;}
for len in len.iter_mut().take(280).skip(288) {*len = 8;} for i in 280..288 {len[i] = 8;}
let dst = [5; 30]; let dst = [5; 30];
@ -393,13 +394,13 @@ impl HuffmanTable
code <<= 1; code <<= 1;
} }
Err(err_msg("code not found in symbol tree")) Err(repr_error(code))
} }
} }
struct HuffmanTable struct HuffmanTable
{ {
nums: [u8; 16], nums: [u16; 16],
syms: Vec<u16>, syms: Vec<u16>,
} }