From ee57bd48f406fe5bc4aa7fdabddacc142e975317 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Mon, 27 Jul 2026 10:12:46 +0200 Subject: [PATCH] perf: Use hash map to check if path was already checked Faster than using in_array Signed-off-by: Carl Schwan --- lib/private/Files/Cache/Watcher.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Cache/Watcher.php b/lib/private/Files/Cache/Watcher.php index 48c5e323514ae..ce8da5c1c4987 100644 --- a/lib/private/Files/Cache/Watcher.php +++ b/lib/private/Files/Cache/Watcher.php @@ -19,6 +19,7 @@ */ class Watcher implements IWatcher { protected int $watchPolicy = self::CHECK_ONCE; + /** @var array $checkedPaths */ protected array $checkedPaths = []; protected ICache $cache; protected IScanner $scanner; @@ -121,8 +122,8 @@ public function needsUpdate($path, $cachedData) { } } - if ($this->watchPolicy === self::CHECK_ALWAYS || ($this->watchPolicy === self::CHECK_ONCE && !in_array($path, $this->checkedPaths))) { - $this->checkedPaths[] = $path; + if ($this->watchPolicy === self::CHECK_ALWAYS || ($this->watchPolicy === self::CHECK_ONCE && !isset($this->checkedPaths[$path]))) { + $this->checkedPaths[$path] = true; return $cachedData['storage_mtime'] === null || $this->storage->hasUpdated($path, $cachedData['storage_mtime']); } return false;