patch: make BufReader preload its buffer
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
This commit is contained in:
parent
a575fe4934
commit
f6a137cd43
@ -1,7 +1,7 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{BufReader, Read, Seek},
|
io::{BufRead, BufReader, Read, Seek},
|
||||||
os::unix::prelude::PermissionsExt,
|
os::unix::prelude::PermissionsExt,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::atomic::{AtomicU64, Ordering},
|
sync::atomic::{AtomicU64, Ordering},
|
||||||
@ -175,7 +175,11 @@ impl LocalFile {
|
|||||||
path: self.path.clone(),
|
path: self.path.clone(),
|
||||||
err: e,
|
err: e,
|
||||||
})?;
|
})?;
|
||||||
let reader = BufReader::with_capacity(BLOCK_SIZE as usize, handle);
|
let mut reader = BufReader::with_capacity(BLOCK_SIZE as usize * 2, handle);
|
||||||
|
reader.fill_buf().map_err(|e| CliprdrError::FileError {
|
||||||
|
path: self.path.clone(),
|
||||||
|
err: e,
|
||||||
|
})?;
|
||||||
self.handle = Some(reader);
|
self.handle = Some(reader);
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user