Skip to content

perf: use fxhash in zip data structures #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/zip.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use std::{
error::Error,
io::{Cursor, Read},
};

use byteorder::{LittleEndian, ReadBytesExt};
use std::collections::{HashMap, HashSet};
use std::error::Error;
use std::io::Cursor;
use std::io::Read;
use rustc_hash::{FxHashMap, FxHashSet};

use crate::fs::FileType;
use crate::util;
Expand All @@ -26,8 +28,8 @@ where
T: AsRef<[u8]>,
{
storage: T,
pub files: HashMap<String, Entry>,
pub dirs: HashSet<String>,
pub files: FxHashMap<String, Entry>,
pub dirs: FxHashSet<String>,
}

impl<T> Zip<T>
Expand Down Expand Up @@ -103,8 +105,8 @@ fn make_io_utf8_error() -> std::io::Error {
std::io::Error::new(std::io::ErrorKind::InvalidData, "File did not contain valid UTF-8")
}

pub fn list_zip_entries(data: &[u8]) -> Result<HashMap<String, Option<Entry>>, Box<dyn Error>> {
let mut zip_entries = HashMap::new();
pub fn list_zip_entries(data: &[u8]) -> Result<FxHashMap<String, Option<Entry>>, Box<dyn Error>> {
let mut zip_entries = FxHashMap::default();
let mut cursor = Cursor::new(data);

let central_directory_offset = find_central_directory_offset(&mut cursor)?;
Expand Down