diff --git a/pkstrings/src/lib.rs b/pkstrings/src/lib.rs index 2216e40..f1ee4e7 100644 --- a/pkstrings/src/lib.rs +++ b/pkstrings/src/lib.rs @@ -114,7 +114,8 @@ lazy_static! { } map }; - static ref HEXTOSTR: HashMap = { + + static ref HEXTOSTR: Vec> = { let tmp = [ (0x80, 'A'), (0x81, 'B'), @@ -202,11 +203,11 @@ lazy_static! { (0x50, '@'), ]; - let mut map = HashMap::new(); + let mut vec: Vec> = [None; 255].to_vec(); for (k, v) in tmp.iter() { - map.insert(*k, *v); + vec[*k] = Some(*v); } - map + vec }; } @@ -240,8 +241,9 @@ impl TryFrom<&[u8]> for PKString { let placeholder = '_'; for ord in data { - if let Some(chr) = HEXTOSTR.get(&ord) { - buf.push(*chr); + let ord = *ord as usize; + if let Some(chr) = HEXTOSTR[ord] { + buf.push(chr.clone()); } else { buf.push(placeholder); }