diff --git a/repak/src/pak.rs b/repak/src/pak.rs index f2dc716..9223643 100644 --- a/repak/src/pak.rs +++ b/repak/src/pak.rs @@ -643,7 +643,7 @@ fn generate_full_directory_index( entries: &BTreeMap, offsets: &Vec, ) -> Result<(), super::Error> { - let mut fdi = BTreeMap::new(); + let mut fdi: BTreeMap<&str, BTreeMap<&str, u32>> = Default::default(); for (path, offset) in entries.keys().zip(offsets) { let mut p = path.as_str(); while let Some((parent, _)) = split_path_child(p) { @@ -653,15 +653,7 @@ fn generate_full_directory_index( let (directory, filename) = split_path_child(path).expect("none root path"); - fdi.entry(directory) - .and_modify(|d: &mut BTreeMap<&str, u32>| { - d.insert(filename, *offset); - }) - .or_insert_with(|| { - let mut files_and_offsets = BTreeMap::new(); - files_and_offsets.insert(filename, *offset); - files_and_offsets - }); + fdi.entry(directory).or_default().insert(filename, *offset); } writer.write_u32::(fdi.len() as u32)?;