Preallocate (safe) slices when we know the size (#10459)

This commit is contained in:
Klaus Post
2020-09-14 20:44:18 -07:00
committed by GitHub
parent b1c99e88ac
commit 34859c6d4b
7 changed files with 42 additions and 46 deletions

View File

@@ -829,8 +829,9 @@ func (client *peerRESTClient) ConsoleLog(logCh chan interface{}, doneCh <-chan s
}
func getRemoteHosts(endpointZones EndpointZones) []*xnet.Host {
var remoteHosts []*xnet.Host
for _, hostStr := range GetRemotePeers(endpointZones) {
peers := GetRemotePeers(endpointZones)
remoteHosts := make([]*xnet.Host, 0, len(peers))
for _, hostStr := range peers {
host, err := xnet.ParseHost(hostStr)
if err != nil {
logger.LogIf(GlobalContext, err)