hashbrown's hashmap with_capacity no work >:/

This commit is contained in:
spuds 2023-01-11 10:25:53 +00:00
parent cd9f5ba98d
commit b268b8e8ac
No known key found for this signature in database
GPG key ID: 0B6CA6068E827C8F

View file

@ -10,6 +10,7 @@ pub struct Pak {
pub version: Version, pub version: Version,
pub footer: super::Footer, pub footer: super::Footer,
pub mount_point: String, pub mount_point: String,
pub entries: hashbrown::HashMap<String, super::Entry>,
} }
impl Pak { impl Pak {
@ -21,17 +22,19 @@ impl Pak {
let footer = super::Footer::new(&mut reader, version)?; let footer = super::Footer::new(&mut reader, version)?;
reader.seek(io::SeekFrom::Start(footer.offset))?; reader.seek(io::SeekFrom::Start(footer.offset))?;
let mount_point = reader.read_string()?; let mount_point = reader.read_string()?;
let mut entries = hashbrown::HashMap::with_capacity(reader.read_u32::<LE>()? as usize); let len = reader.read_u32::<LE>()? as usize;
for _ in 0..entries.capacity() { let mut entries = hashbrown::HashMap::with_capacity(len);
for _ in 0..len {
entries.insert( entries.insert(
dbg!(reader.read_string()?), reader.read_string()?,
dbg!(super::Entry::new(&mut reader, version)?), super::Entry::new(&mut reader, version)?,
); );
} }
Ok(Self { Ok(Self {
version, version,
footer, footer,
mount_point, mount_point,
entries,
}) })
} }
} }