mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-01 09:32:08 +00:00
cmd/cloner,*: revert: optimize nillable slice cloner
This reverts commit ee90cd02fd.
The outcome is not identical for empty slices. Cloner really needs
tests!
Updates #9601
Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
committed by
James Tucker
parent
ee90cd02fd
commit
324f0d5f80
@@ -23,9 +23,11 @@ func (src *Match) Clone() *Match {
|
||||
dst.IPProto = append(src.IPProto[:0:0], src.IPProto...)
|
||||
dst.Srcs = append(src.Srcs[:0:0], src.Srcs...)
|
||||
dst.Dsts = append(src.Dsts[:0:0], src.Dsts...)
|
||||
dst.Caps = append([]CapMatch(nil), make([]CapMatch, len(src.Caps))...)
|
||||
for i := range dst.Caps {
|
||||
dst.Caps[i] = *src.Caps[i].Clone()
|
||||
if src.Caps != nil {
|
||||
dst.Caps = make([]CapMatch, len(src.Caps))
|
||||
for i := range dst.Caps {
|
||||
dst.Caps[i] = *src.Caps[i].Clone()
|
||||
}
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user