range
CRT-P0005Use pointer to slice
or array
, to avoid copying the value that is ranged
over.
var xs [2048]byte
for _, x := range xs { // copies 2048 bytes
// Loop body.
}
var xs [2048]byte
for _, x := range &xs { // only address is copied now
// Loop body.
}