clientv3: preallocate watch streams slice

To avoid slice growth when appending
This commit is contained in:
Gyu-Ho Lee 2016-05-19 12:55:55 -07:00
parent edb11881f8
commit f9306fb817

View File

@ -520,8 +520,8 @@ func (w *watcher) openWatchClient() (ws pb.Watch_WatchClient, err error) {
// resumeWatchers rebuilds every registered watcher on a new client
func (w *watcher) resumeWatchers(wc pb.Watch_WatchClient) error {
streams := []*watcherStream{}
w.mu.RLock()
streams := make([]*watcherStream, 0, len(w.streams))
for _, ws := range w.streams {
streams = append(streams, ws)
}