From: Rui Ueyama Date: Tue, 17 Jun 2014 01:00:28 +0000 (-0700) Subject: net: avoid array copy when shuffling SRV records X-Git-Tag: go1.4beta1~1283 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=38eea5b2ad6a6bf108cf4445506559118e34d782;p=gostls13.git net: avoid array copy when shuffling SRV records We don't need to shift array elements to shuffle them. We just have to swap a selected element with 0th element. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/91750044 --- diff --git a/src/pkg/net/dnsclient.go b/src/pkg/net/dnsclient.go index 9bffa11f91..e8014e4ffc 100644 --- a/src/pkg/net/dnsclient.go +++ b/src/pkg/net/dnsclient.go @@ -196,9 +196,7 @@ func (addrs byPriorityWeight) shuffleByWeight() { s += int(addrs[i].Weight) if s > n { if i > 0 { - t := addrs[i] - copy(addrs[1:i+1], addrs[0:i]) - addrs[0] = t + addrs[0], addrs[i] = addrs[i], addrs[0] } break }