mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-28 10:40:48 +00:00
Optimize file table creation, fixes #484 as a side-effect
This commit is contained in:
parent
89c861f24d
commit
bbd6db3687
@ -61,6 +61,7 @@
|
||||
|
||||
|
||||
use std::io::{Write, Error as IOError, Result as IOResult};
|
||||
use std::mem::MaybeUninit;
|
||||
use std::path::PathBuf;
|
||||
use std::vec::IntoIter as VecIntoIter;
|
||||
|
||||
@ -192,13 +193,13 @@ impl<'a> Render<'a> {
|
||||
use std::sync::{Arc, Mutex};
|
||||
use fs::feature::xattr;
|
||||
|
||||
let mut file_eggs = Vec::new();
|
||||
let mut file_eggs = (0..src.len()).map(|_| MaybeUninit::uninit()).collect::<Vec<_>>();
|
||||
|
||||
pool.scoped(|scoped| {
|
||||
let file_eggs = Arc::new(Mutex::new(&mut file_eggs));
|
||||
let table = table.as_ref();
|
||||
|
||||
for file in src {
|
||||
for (idx, file) in src.iter().enumerate() {
|
||||
let file_eggs = Arc::clone(&file_eggs);
|
||||
|
||||
scoped.execute(move || {
|
||||
@ -265,11 +266,13 @@ impl<'a> Render<'a> {
|
||||
} else { None };
|
||||
|
||||
let egg = Egg { table_row, xattrs, errors, dir, file, icon };
|
||||
file_eggs.lock().unwrap().push(egg);
|
||||
unsafe { std::ptr::write(file_eggs.lock().unwrap()[idx].as_mut_ptr(), egg) }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// this is safe because all entries have been initialized above
|
||||
let mut file_eggs = unsafe { std::mem::transmute::<_, Vec<Egg>>(file_eggs) };
|
||||
self.filter.sort_files(&mut file_eggs);
|
||||
|
||||
for (tree_params, egg) in depth.iterate_over(file_eggs.into_iter()) {
|
||||
|
Loading…
Reference in New Issue
Block a user