Preallocate slice

Proprietary

Add a capacity to a slice made empty and then filled by appending over a range, so out := make([]int, 0) before for _, x := range xs becomes make([]int, 0, len(xs)). The capacity is a hint, so only the allocation changes.

org.openrewrite.golang.codequality.PreallocateSlice
mod run . --recipe=org.openrewrite.golang.codequality.PreallocateSlice

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.