Skip to content

Commit 0e7f01c

Browse files
authored
Make performance of String::insert_str more precise
1 parent 4d30011 commit 0e7f01c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/alloc/src/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,8 +1725,8 @@ 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+
/// If there is space in `self` this will copy `self.len() - idx + string.len()` bytes,
1729+
/// otherwise will reallocate and copy `self.len() + string.len()` bytes.
17301730
///
17311731
/// # Panics
17321732
///

0 commit comments

Comments
 (0)