Skip to content

Commit aa594fe

Browse files
committed
Make performance of String::insert_str more precise
1 parent 4d30011 commit aa594fe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

library/alloc/src/string.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1725,8 +1725,10 @@ impl String {
17251725

17261726
/// Inserts a string slice into this `String` at a byte position.
17271727
///
1728-
/// This is an *O*(*n*) operation as it requires copying every element in the
1729-
/// buffer.
1728+
/// Reallocates if `self.capacity()` is insufficient,
1729+
/// (which may involve copying all `self.capacity()` bytes).
1730+
/// Makes space at the given position for the insertion,
1731+
/// by moving the bytes, from the given position until the end, to new positions.
17301732
///
17311733
/// # Panics
17321734
///

0 commit comments

Comments
 (0)