Skip to content

Commit 8022523

Browse files
committed
Auto merge of rust-lang#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
2 parents 7a82eb5 + 95bff3e commit 8022523

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

alloc/src/str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ impl str {
531531
#[rustc_allow_incoherent_impl]
532532
#[must_use]
533533
#[stable(feature = "repeat_str", since = "1.16.0")]
534+
#[inline]
534535
pub fn repeat(&self, n: usize) -> String {
535536
unsafe { String::from_utf8_unchecked(self.as_bytes().repeat(n)) }
536537
}

0 commit comments

Comments
 (0)