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.
This commit is contained in:
Gyu-Ho Lee
2016-01-04 22:34:48 -08:00
parent d9d1342869
commit 7339abc79e

View File

@@ -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: