mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-12-29 04:23:26 +00:00
perf: only check timeout every 256 files (#1499)
This commit is contained in:
parent
b8359a860a
commit
3818f901d4
@ -204,8 +204,12 @@ impl DirContents {
|
||||
let mut extensions: HashSet<String> = HashSet::new();
|
||||
|
||||
fs::read_dir(base)?
|
||||
.take_while(|_| SystemTime::now().duration_since(start).unwrap() < timeout)
|
||||
.filter_map(Result::ok)
|
||||
.enumerate()
|
||||
.take_while(|(n, _)| {
|
||||
n & 0xFF != 0 // only check SystemTime once every 2^8 entries
|
||||
|| SystemTime::now().duration_since(start).unwrap() < timeout
|
||||
})
|
||||
.filter_map(|(_, entry)| entry.ok())
|
||||
.for_each(|entry| {
|
||||
let path = PathBuf::from(entry.path().strip_prefix(base).unwrap());
|
||||
if entry.path().is_dir() {
|
||||
|
Loading…
Reference in New Issue
Block a user