From a56060b558d642a2accde9625686aacc93684ab4 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sun, 12 Jan 2014 10:04:38 +0000 Subject: [PATCH] Cleanups for Copy() Docs and slight code formatting issues. --- msg.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/msg.go b/msg.go index 0710ba58..8cf73da1 100644 --- a/msg.go +++ b/msg.go @@ -1545,30 +1545,27 @@ func (dns *Msg) Len() int { return l } -// Create a deep-copy +// Copy returns a new *Msg which is a deep-copy of dns. func (dns *Msg) Copy() *Msg { r1 := new(Msg) r1.MsgHdr = dns.MsgHdr r1.Compress = dns.Compress r1.Question = make([]Question, len(dns.Question)) - copy(r1.Question, dns.Question) // Question is an immutable value, ok to do a shallow-copy + copy(r1.Question, dns.Question) // TODO(miek): Question is an immutable value, ok to do a shallow-copy r1.Answer = make([]RR, len(dns.Answer)) for i := 0; i < len(dns.Answer); i++ { r1.Answer[i] = dns.Answer[i].copy() } - r1.Ns = make([]RR, len(dns.Ns)) for i := 0; i < len(dns.Ns); i++ { r1.Ns[i] = dns.Ns[i].copy() } - r1.Extra = make([]RR, len(dns.Extra)) for i := 0; i < len(dns.Extra); i++ { r1.Extra[i] = dns.Extra[i].copy() } - return r1 }