reduce the number of string copy operations.

This commit is contained in:
Nan Monnand Deng 2013-07-01 17:57:56 -04:00
parent 34cf976866
commit 73e79a3310

View file

@ -116,9 +116,11 @@ func (r *Registry) setUserAgent(req *http.Request, extra ...VersionChecker) {
if len(r.baseVersions)+len(extra) == 0 {
return
}
userAgent := appendVersions(r.baseVersionsStr, extra...)
req.Header.Set("User-Agent", userAgent)
if len(extra) == 0 {
req.Header.Set("User-Agent", r.baseVersionsStr)
} else {
req.Header.Set("User-Agent", appendVersions(r.baseVersionsStr, extra...))
}
return
}