From 7339abc79eb9c5829bb7252e0669059d35bf2a23 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 4 Jan 2016 22:34:48 -0800 Subject: [PATCH] storage: fix watchable_store notify to hash-lookup once We should just assign events and ok at first, and check the boolean value, instead of looking up the map twice. --- storage/watchable_store.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/watchable_store.go b/storage/watchable_store.go index 0635da822..e66ff5599 100644 --- a/storage/watchable_store.go +++ b/storage/watchable_store.go @@ -375,10 +375,10 @@ func (s *watchableStore) notify(rev int64, evs []storagepb.Event) { we := newWatcherToEventMap(s.synced, evs) for _, wm := range s.synced { for w := range wm { - if _, ok := we[w]; !ok { + es, ok := we[w] + if !ok { continue } - es := we[w] wr := WatchResponse{WatchID: w.id, Events: es} select { case w.ch <- wr: