Skip to content

Commit

Permalink
Merge pull request #271 from nickbabcock/zip-mmap
Browse files Browse the repository at this point in the history
Prefer buffer to mmap for zip file
  • Loading branch information
nickbabcock authored Dec 13, 2024
2 parents 0a33584 + 57b18b6 commit 5a167a1
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 5a167a1

Please sign in to comment.