Preallocate slice
ProprietaryAdd 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. PreallocateSlicemod run . --recipe= org. openrewrite. golang. codequality. PreallocateSliceInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.