Skip to content

Commit

Permalink
Prefer buffer to mmap for zip file
Browse files Browse the repository at this point in the history
Makes it confusing looking at large reserved memory when in reality it
is just mmap.

Performance remains unchanged.
  • Loading branch information
nickbabcock committed Dec 13, 2024
1 parent 0a33584 commit 57b18b6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use rayon::iter::ParallelBridge;
use rayon::prelude::*;
use serde::Serialize;
use std::fs::{self, OpenOptions};
use std::io::{self, BufWriter};
use std::io::{prelude::*, Cursor};
use std::io::prelude::*;
use std::io::{self, BufReader, BufWriter};
use std::path::{Path, PathBuf};
use std::sync::mpsc::{channel, sync_channel};
use std::thread;
Expand Down Expand Up @@ -255,8 +255,7 @@ fn zip(file_path: &Path, opt: &Opt) -> anyhow::Result<()> {
let (return_buf, receive_buf) = channel::<Vec<u8>>();

let f = fs::File::open(file_path)?;
let mmap = unsafe { memmap2::MmapOptions::new().map(&f)? };
let zipreader = Cursor::new(&mmap);
let zipreader = BufReader::new(f);
let mut archive = zip::ZipArchive::new(zipreader)?;

thread::scope(|scope| {
Expand Down

0 comments on commit 57b18b6

Please sign in to comment.