]> go.fuhry.dev Git - fsnotify.git/commit
kqueue: Make watcher.Close() O(n) instead of O(n^2) (#233)
authorNick Santos <nick.santos@docker.com>
Thu, 21 Jul 2022 10:20:14 +0000 (11:20 +0100)
committerGitHub <noreply@github.com>
Thu, 21 Jul 2022 10:20:14 +0000 (12:20 +0200)
commit6ae56b78f545a5be2fc9e9bb6013443a35716fc4
tree7fa971f68b66abc95825b4b0e45eba646cd647a3
parentadf5320df4676326c2f2612c2168c2113a7e6540
kqueue: Make watcher.Close() O(n) instead of O(n^2) (#233)

In the old implementation watcher.Close() would clone the list of
watches and then run Remove() on that, and every Remove() call would
iterate over the full list of watches.

This stores the watches more efficiently so that Remove() doesn't need
to iterate over the full list: instead of merely a path → fd map, it
also stores a parent-path → list-of-files.

No functional changes, just a performance improvement.
kqueue.go