Lazily allocate inotify map on inode

PiperOrigin-RevId: 235735865
Change-Id: I84223eb18eb51da1fa9768feaae80387ff6bfed0
This commit is contained in:
Fabricio Voznika
2019-02-26 09:33:44 -08:00
committed by Shentubot
parent 33d0e824c7
commit 23fe059761
+4 -3
View File
@@ -39,9 +39,7 @@ type Watches struct {
}
func newWatches() *Watches {
return &Watches{
ws: make(map[uint64]*Watch),
}
return &Watches{}
}
// MarkUnlinked indicates the target for this set of watches to be unlinked.
@@ -78,6 +76,9 @@ func (w *Watches) Add(watch *Watch) {
if _, exists := w.ws[watch.ID()]; exists {
panic(fmt.Sprintf("Watch collision with ID %+v", watch.ID()))
}
if w.ws == nil {
w.ws = make(map[uint64]*Watch)
}
w.ws[watch.ID()] = watch
}