Browse Source

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.
Gyu-Ho Lee 10 years ago
parent
commit
7339abc79e
1 changed files with 2 additions and 2 deletions
  1. 2 2
      storage/watchable_store.go

+ 2 - 2
storage/watchable_store.go

@@ -375,10 +375,10 @@ func (s *watchableStore) notify(rev int64, evs []storagepb.Event) {
 	we := newWatcherToEventMap(s.synced, evs)
 	we := newWatcherToEventMap(s.synced, evs)
 	for _, wm := range s.synced {
 	for _, wm := range s.synced {
 		for w := range wm {
 		for w := range wm {
-			if _, ok := we[w]; !ok {
+			es, ok := we[w]
+			if !ok {
 				continue
 				continue
 			}
 			}
-			es := we[w]
 			wr := WatchResponse{WatchID: w.id, Events: es}
 			wr := WatchResponse{WatchID: w.id, Events: es}
 			select {
 			select {
 			case w.ch <- wr:
 			case w.ch <- wr: