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:
parent
5df776dde5
commit
59d7433ecf
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user