Mercurial > minori
changeset 391:c3f717b7321b
filesystem: only iterate over the list once when erasing deleted files
:)
| author | Paper <paper@tflc.us> |
|---|---|
| date | Fri, 07 Nov 2025 07:09:31 -0500 |
| parents | 2d3e10319112 |
| children | a72d6d7b3568 |
| files | src/core/filesystem.cc |
| diffstat | 1 files changed, 6 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/filesystem.cc Fri Nov 07 07:08:57 2025 -0500 +++ b/src/core/filesystem.cc Fri Nov 07 07:09:31 2025 -0500 @@ -79,8 +79,9 @@ }; /* ------------------------------------------------------------------------ */ -/* Non-recursive filesystem watcher. - * This is the portable version for non-Windows */ +/* Filesystem watcher. + * This is the portable version for non-Windows (of which the Windows + * specific version hasn't been written yet... TODO) */ template<typename T> class StdFilesystemWatcher : public Watcher { @@ -115,7 +116,8 @@ } protected: - bool FindAndTogglePath(const std::filesystem::path &p) { + bool FindAndTogglePath(const std::filesystem::path &p) + { for (auto &pp : paths_) { if (pp.path == p) { pp.found = true; @@ -134,14 +136,11 @@ void DeleteUntoggledPaths() { - for (const auto &path : paths_) - if (!path.found) - handler_(opaque_, path.path, Event::Deleted); - auto it = paths_.begin(); while (it != paths_.end()) { if (!it->found) { + handler_(opaque_, it->path, Event::Deleted); it = paths_.erase(it); } else { it++;
