From 0e7f01ce37a433960936789c3e9c07645e7e06cb Mon Sep 17 00:00:00 2001
From: Marijn Schouten <hkBst@users.noreply.github.com>
Date: Sat, 15 Mar 2025 16:16:08 +0100
Subject: [PATCH] Make performance of String::insert_str more precise

---
 library/alloc/src/string.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
index 9236f5cb8d1f0..c38634d300070 100644
--- a/library/alloc/src/string.rs
+++ b/library/alloc/src/string.rs
@@ -1725,8 +1725,8 @@ impl String {
 
     /// Inserts a string slice into this `String` at a byte position.
     ///
-    /// This is an *O*(*n*) operation as it requires copying every element in the
-    /// buffer.
+    /// If there is space in `self` this will copy `self.len() - idx + string.len()` bytes,
+    /// otherwise will reallocate and copy `self.len() + string.len()` bytes.
     ///
     /// # Panics
     ///