Browse Source

rafthttp: replace append with pre-allocated slice

Gyu-Ho Lee 9 years ago
parent
commit
c9264c5e65
1 changed files with 3 additions and 3 deletions
  1. 3 3
      rafthttp/util.go

+ 3 - 3
rafthttp/util.go

@@ -197,9 +197,9 @@ func setPeerURLsHeader(req *http.Request, urls types.URLs) {
 		// often not set in unit tests
 		return
 	}
-	var peerURLs []string
-	for _, url := range urls {
-		peerURLs = append(peerURLs, url.String())
+	peerURLs := make([]string, urls.Len())
+	for i := range urls {
+		peerURLs[i] = urls[i].String()
 	}
 	req.Header.Set("X-PeerURLs", strings.Join(peerURLs, ","))
 }