about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJan Bujak <j@exia.io>2015-05-03 12:09:40 +0200
committerJan Bujak <j@exia.io>2015-05-03 12:09:40 +0200
commit91ea0c4f12574627dc9a17c7acce1c0258797a36 (patch)
tree2489f310340eebf6b777b49d7747896b8076e4c2
parent0d7d3ec9d2b314af0188a820c58fbd95ee905793 (diff)
downloadrust-91ea0c4f12574627dc9a17c7acce1c0258797a36.tar.gz
rust-91ea0c4f12574627dc9a17c7acce1c0258797a36.zip
Add #[inline(always)] to str::from_utf8_unchecked
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.
-rw-r--r--src/libcore/str/mod.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs
index 4d343ea0f1e..6b65d746256 100644
--- a/src/libcore/str/mod.rs
+++ b/src/libcore/str/mod.rs
@@ -136,6 +136,7 @@ pub fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
 
 /// Converts a slice of bytes to a string slice without checking
 /// that the string contains valid UTF-8.
+#[inline(always)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub unsafe fn from_utf8_unchecked<'a>(v: &'a [u8]) -> &'a str {
     mem::transmute(v)