mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
clientv3: preallocate watch streams slice
To avoid slice growth when appending
This commit is contained in:
parent
edb11881f8
commit
f9306fb817
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user