Test out buffered writes

This commit is contained in:
Gregory 2020-09-03 22:12:04 -04:00
parent 977f2cb8a1
commit 3242ef602d
No known key found for this signature in database
GPG key ID: 2E44FAEEDC94B1E2

View file

@ -3,6 +3,7 @@ use regex::bytes::Regex;
use std::{
fs::File,
io::prelude::*,
io::BufWriter,
path::{Path, PathBuf},
};
@ -124,7 +125,8 @@ impl Replacer {
if !replaced.is_empty() {
let mut mmap_target = unsafe { MmapMut::map_mut(&file)? };
mmap_target.deref_mut().write_all(&replaced)?;
BufWriter::with_capacity(1_000_000_000, mmap_target.deref_mut())
.write_all(&replaced)?;
mmap_target.flush_async()?;
}