From: Jes Cok Date: Sat, 30 Mar 2024 02:32:20 +0000 (+0800) Subject: slices: simplify slice expression for Replace X-Git-Tag: go1.23rc1~704 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=170862d68377ac04a35223521ce9e450007a6032;p=gostls13.git slices: simplify slice expression for Replace A slice expression of the form: s[a:len(s)] will be simplified to: s[a:] This is one of the simplifications that "gofmt -s" applies. See https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/simplifyslice Change-Id: Ib3c01ecf24b84333fd1993a343450fc57fb8ac84 Reviewed-on: https://go-review.googlesource.com/c/go/+/575335 Reviewed-by: Ian Lance Taylor Commit-Queue: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Auto-Submit: Ian Lance Taylor Reviewed-by: Valentin Deleplace --- diff --git a/src/slices/slices.go b/src/slices/slices.go index 271e8cb325..a5734a17bf 100644 --- a/src/slices/slices.go +++ b/src/slices/slices.go @@ -261,7 +261,7 @@ func Replace[S ~[]E, E any](s S, i, j int, v ...E) S { if j == len(s) { s2 := append(s[:i], v...) if len(s2) < len(s) { - clear(s[len(s2):len(s)]) // zero/nil out the obsolete elements, for GC + clear(s[len(s2):]) // zero/nil out the obsolete elements, for GC } return s2 }