Rollup merge of #25158 - koute:master, r=alexcrichton

I was profiling my code again and this time AsRef<str> for String
was eating up a considerable chunk of my runtime; adding the inline
annotation made the program run almost twice as fast!

While I was at it I also added the annotation to other implementations
of AsRef as well as AsMut.
This commit is contained in:
Steve Klabnik 2015-05-10 16:44:22 -04:00
commit ad1c0c57b8
2 changed files with 2 additions and 0 deletions

View file

@ -1052,6 +1052,7 @@ impl<T: fmt::Display + ?Sized> ToString for T {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl AsRef<str> for String { impl AsRef<str> for String {
#[inline]
fn as_ref(&self) -> &str { fn as_ref(&self) -> &str {
self self
} }

View file

@ -173,6 +173,7 @@ impl<T> AsMut<[T]> for [T] {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl AsRef<str> for str { impl AsRef<str> for str {
#[inline]
fn as_ref(&self) -> &str { fn as_ref(&self) -> &str {
self self
} }