1
0
mirror of https://github.com/golang/go synced 2024-09-28 22:14:28 -06:00

impove the bound check line in Delete

This commit is contained in:
go101 2023-11-16 00:54:22 +08:00
parent 5df776dde5
commit 59d7433ecf

View File

@ -217,7 +217,7 @@ func Insert[S ~[]E, E any](s S, i int, v ...E) S {
// make a single call deleting them all together than to delete one at a time.
// Delete zeroes the elements s[len(s)-(j-i):len(s)].
func Delete[S ~[]E, E any](s S, i, j int) S {
_ = s[i:j] // bounds check
_ = s[i:j:len(s)] // bounds check
if i == j {
return s