Go

Go

Made by DeepSource

Copy of large value in range CRT-P0005

Performance
Major
Autofix

Use pointer to slice or array, to avoid copying the value that is ranged over.

Bad practice

var xs [2048]byte
for _, x := range xs { // copies 2048 bytes
    // Loop body.
}

Recommended

var xs [2048]byte
for _, x := range &xs { // only address is copied now
    // Loop body.
}