Skip to content

Commit 1ea9e8d

Browse files
committed
Auto merge of #25067 - koute:master, r=alexcrichton
Without the inline annotation this: str::from_utf8_unchecked( slice::from_raw_parts( ptr, len ) ) doesn't get inlined which can be pretty brutal performance-wise when used in an inner loop of a low level string manipulation method.
2 parents 6517a0e + 91ea0c4 commit 1ea9e8d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/libcore/str/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ pub fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
136136

137137
/// Converts a slice of bytes to a string slice without checking
138138
/// that the string contains valid UTF-8.
139+
#[inline(always)]
139140
#[stable(feature = "rust1", since = "1.0.0")]
140141
pub unsafe fn from_utf8_unchecked<'a>(v: &'a [u8]) -> &'a str {
141142
mem::transmute(v)

0 commit comments

Comments
 (0)