Skip to content

Commit bd9bcdd

Browse files
Deleplacerandall77
authored andcommitted
slices.Delete: fix runtime complexity documentation
O(len(s)-j) i.e. proportional to the number of elements shifted to the left. Fixes golang/go#54699 Change-Id: Ifffeca54e0f53289015864aa301f20b9344befb9 Reviewed-on: https://go-review.googlesource.com/c/exp/+/425994 Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 4cc3b17 commit bd9bcdd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

slices/slices.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func Insert[S ~[]E, E any](s S, i int, v ...E) S {
151151
// Delete removes the elements s[i:j] from s, returning the modified slice.
152152
// Delete panics if s[i:j] is not a valid slice of s.
153153
// Delete modifies the contents of the slice s; it does not create a new slice.
154-
// Delete is O(len(s)-(j-i)), so if many items must be deleted, it is better to
154+
// Delete is O(len(s)-j), so if many items must be deleted, it is better to
155155
// make a single call deleting them all together than to delete one at a time.
156156
func Delete[S ~[]E, E any](s S, i, j int) S {
157157
_ = s[i:j] // bounds check

0 commit comments

Comments
 (0)