]> go.fuhry.dev Git - fsnotify.git/commit
inotify: simplify bookkeeping of watched paths (#543)
authorMartin Tournoij <martin@arp242.net>
Sat, 14 Jan 2023 17:28:20 +0000 (18:28 +0100)
committerGitHub <noreply@github.com>
Sat, 14 Jan 2023 17:28:20 +0000 (18:28 +0100)
commit16df002ca5dd174de0722cd26bfe5952487f2a95
tree9230112a1d025c4bdb0966330f77154d8be30936
parentc6f5cfa163edb0f1bb78be3a77053ee14c48a3ce
inotify: simplify bookkeeping of watched paths (#543)

Create a new watches type to keep track of the watches instead of
keeping two maps on the Watcher and accessing these directly.

This makes the bookkeeping a bit easier to follow, and we no longer need
to worry about locking map access as the watcher type takes care of that
now.

Came up in #472 where I want to keep track if a path was added
recursively, and this makes that a bit easier.

Also seems a bit faster:

BenchmarkWatch-2          903709              7122 ns/op             194 B/op          3 allocs/op
BenchmarkWatch-2          923980              6322 ns/op             196 B/op          3 allocs/op

Although that benchmark is very simply and only tests one code path;
just want to make sure it's not a horrible regression.
backend_inotify.go
backend_inotify_test.go
fsnotify_test.go