mirror of
https://github.com/starship/starship.git
synced 2025-02-27 15:53:02 +01: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();
|
let mut extensions: HashSet<String> = HashSet::new();
|
||||||
|
|
||||||
fs::read_dir(base)?
|
fs::read_dir(base)?
|
||||||
.take_while(|_| SystemTime::now().duration_since(start).unwrap() < timeout)
|
.enumerate()
|
||||||
.filter_map(Result::ok)
|
.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| {
|
.for_each(|entry| {
|
||||||
let path = PathBuf::from(entry.path().strip_prefix(base).unwrap());
|
let path = PathBuf::from(entry.path().strip_prefix(base).unwrap());
|
||||||
if entry.path().is_dir() {
|
if entry.path().is_dir() {
|
||||||
|
Loading…
Reference in New Issue
Block a user