Go

Go

Made by DeepSource

Copy of large value inside loop CRT-P0006

Performance
Major

Avoid for loop range expressions that copy big objects for each iteration. It is recommended to use index-based access or use pointers instead.

Bad practice

xs := make([][1024]byte, length)
for _, x := range xs {
    // Loop body.
}

Recommended

xs := make([][1024]byte, length)
for i := range xs {
    x := &xs[i]
    // Loop body.
}