remove pointer to map

This commit is contained in:
Fabrizio (Misto) Milo 2013-08-06 20:00:50 -07:00 committed by Brandon Philips
parent 140bbfec38
commit f4fc4caf6f
2 changed files with 5 additions and 5 deletions

View File

@ -483,7 +483,7 @@ func (s *Store) TestAndSet(key string, prevValue string, value string, expireTim
// The watchHub will send response to the channel when any key under the prefix // The watchHub will send response to the channel when any key under the prefix
// changes [since the sinceIndex if given] // changes [since the sinceIndex if given]
func (s *Store) AddWatcher(prefix string, watcher *Watcher, sinceIndex uint64) error { func (s *Store) AddWatcher(prefix string, watcher *Watcher, sinceIndex uint64) error {
return s.watcher.addWatcher(prefix, watcher, sinceIndex, s.ResponseStartIndex, s.Index, &s.ResponseMap) return s.watcher.addWatcher(prefix, watcher, sinceIndex, s.ResponseStartIndex, s.Index, s.ResponseMap)
} }
// This function should be created as a go routine to delete the key-value pair // This function should be created as a go routine to delete the key-value pair

View File

@ -36,14 +36,14 @@ func NewWatcher() *Watcher {
// Add a watcher to the watcherHub // Add a watcher to the watcherHub
func (w *WatcherHub) addWatcher(prefix string, watcher *Watcher, sinceIndex uint64, func (w *WatcherHub) addWatcher(prefix string, watcher *Watcher, sinceIndex uint64,
responseStartIndex uint64, currentIndex uint64, resMap *map[string]*Response) error { responseStartIndex uint64, currentIndex uint64, resMap map[string]*Response) error {
prefix = path.Clean("/" + prefix) prefix = path.Clean("/" + prefix)
if sinceIndex != 0 && sinceIndex >= responseStartIndex { if sinceIndex != 0 && sinceIndex >= responseStartIndex {
for i := sinceIndex; i <= currentIndex; i++ { for i := sinceIndex; i <= currentIndex; i++ {
if checkResponse(prefix, i, resMap) { if checkResponse(prefix, i, resMap) {
watcher.C <- (*resMap)[strconv.FormatUint(i, 10)] watcher.C <- resMap[strconv.FormatUint(i, 10)]
return nil return nil
} }
} }
@ -65,9 +65,9 @@ func (w *WatcherHub) addWatcher(prefix string, watcher *Watcher, sinceIndex uint
} }
// Check if the response has what we are watching // Check if the response has what we are watching
func checkResponse(prefix string, index uint64, resMap *map[string]*Response) bool { func checkResponse(prefix string, index uint64, resMap map[string]*Response) bool {
resp, ok := (*resMap)[strconv.FormatUint(index, 10)] resp, ok := resMap[strconv.FormatUint(index, 10)]
if !ok { if !ok {
// not storage system command // not storage system command