[thin_check (rust)] Use vec::with_capacity() to avoid reallocations.
This commit is contained in:
parent
2cc2dffab5
commit
c9a759b4e8
@ -80,7 +80,7 @@ impl SyncIoEngine {
|
||||
}
|
||||
|
||||
pub fn new(path: &Path, nr_files: usize, writeable: bool) -> Result<SyncIoEngine> {
|
||||
let mut files = Vec::new();
|
||||
let mut files = Vec::with_capacity(nr_files);
|
||||
for _n in 0..nr_files {
|
||||
files.push(SyncIoEngine::open_file(path, writeable)?);
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ impl BTreeWalker {
|
||||
NV: NodeVisitor<V>,
|
||||
V: Unpack,
|
||||
{
|
||||
let mut blocks = Vec::new();
|
||||
let mut blocks = Vec::with_capacity(bs.len());
|
||||
for b in bs {
|
||||
if self.sm_inc(*b)? == 0 {
|
||||
blocks.push(Block::new(*b));
|
||||
|
@ -159,8 +159,8 @@ impl Unpack for Bitmap {
|
||||
fn unpack(data: &[u8]) -> IResult<&[u8], Self> {
|
||||
let (mut i, header) = BitmapHeader::unpack(data)?;
|
||||
|
||||
let mut entries = Vec::new();
|
||||
let nr_words = (BLOCK_SIZE - BitmapHeader::disk_size() as usize) / 8;
|
||||
let mut entries = Vec::with_capacity(nr_words * 32);
|
||||
for _w in 0..nr_words {
|
||||
let (tmp, mut word) = le_u64(i)?;
|
||||
|
||||
|
@ -172,7 +172,7 @@ fn check_space_map(
|
||||
w.walk(&mut v, root.ref_count_root)?;
|
||||
}
|
||||
|
||||
let mut blocks = Vec::new();
|
||||
let mut blocks = Vec::with_capacity(entries.len());
|
||||
for i in &entries {
|
||||
blocks.push(Block::new(i.blocknr));
|
||||
}
|
||||
@ -243,7 +243,7 @@ fn repair_space_map(ctx: &Context, entries: Vec<BitmapLeak>, sm: ASpaceMap) -> R
|
||||
|
||||
let sm = sm.lock().unwrap();
|
||||
|
||||
let mut blocks = Vec::new();
|
||||
let mut blocks = Vec::with_capacity(entries.len());
|
||||
for i in &entries {
|
||||
blocks.push(Block::new(i.loc));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user