summaryrefslogtreecommitdiffstats
path: root/src/context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/context.rs')
-rw-r--r--src/context.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/context.rs b/src/context.rs
index 17a73c688..9076120cf 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -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() {