for
loop with call to copy
for slice SCC-S1001315}
316
317func (r *groupResolver) doomCandidates() {
318 for i, c := range r.candidates {319 r.doomedCandidates[i] = c
320 }
321}
Use copy
for copying slices instead of manually copying the elements in a
loop.
The built-in function copy
assist in common slice operations. The function
copy
copies slice elements from a source src
to a destination dst
and
returns the number of elements copied. Note that the number of elements copied
is the minimum of len(src)
and len(dst)
. Therefore, to copy all the slice
elements from src
to dst
, dst
must satisfy len(dst) >= len(src)
.
copy(dst, src []T) int
for i, elem := range src {
dst[i] = elem
}
copy(dst, src)