Auto merge of #132705 - kornelski:inline-repeat, r=tgross35

Inline str::repeat

`str` is non-generic and `str.repeat()` doesn't get inlined, which makes it use a slower algorithm in case of 1-char repetitions. Equivalent byte slice does get inlined: https://rust.godbolt.org/z/4arvh97r4
This commit is contained in:
bors 2024-11-07 04:26:33 +00:00
commit 546a1eaab9

View File

@ -531,6 +531,7 @@ pub fn into_string(self: Box<str>) -> String {
#[rustc_allow_incoherent_impl]
#[must_use]
#[stable(feature = "repeat_str", since = "1.16.0")]
#[inline]
pub fn repeat(&self, n: usize) -> String {
unsafe { String::from_utf8_unchecked(self.as_bytes().repeat(n)) }
}