diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 6cf062d4f30c0..b9cede7aa53ba 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -495,11 +495,13 @@ impl OsStr { /// /// let os_str = OsStr::new("foo"); /// ``` + #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn new + ?Sized>(s: &S) -> &OsStr { s.as_ref() } + #[inline] fn from_inner(inner: &Slice) -> &OsStr { unsafe { &*(inner as *const Slice as *const OsStr) } } @@ -658,6 +660,7 @@ impl OsStr { /// /// Note: it is *crucial* that this API is private, to avoid /// revealing the internal, platform-specific encodings. + #[inline] fn bytes(&self) -> &[u8] { unsafe { &*(&self.inner as *const _ as *const [u8]) } } @@ -797,6 +800,7 @@ impl Default for &OsStr { #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for OsStr { + #[inline] fn eq(&self, other: &OsStr) -> bool { self.bytes().eq(other.bytes()) } @@ -804,6 +808,7 @@ impl PartialEq for OsStr { #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for OsStr { + #[inline] fn eq(&self, other: &str) -> bool { *self == *OsStr::new(other) } @@ -811,6 +816,7 @@ impl PartialEq for OsStr { #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for str { + #[inline] fn eq(&self, other: &OsStr) -> bool { *other == *OsStr::new(self) } @@ -944,6 +950,7 @@ impl AsRef for OsString { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for str { + #[inline] fn as_ref(&self) -> &OsStr { OsStr::from_inner(Slice::from_str(self)) } @@ -951,6 +958,7 @@ impl AsRef for str { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for String { + #[inline] fn as_ref(&self) -> &OsStr { (&**self).as_ref() } diff --git a/src/libstd/sys/windows/os_str.rs b/src/libstd/sys/windows/os_str.rs index e451e0cfb5bc4..ef260f9c5d21f 100644 --- a/src/libstd/sys/windows/os_str.rs +++ b/src/libstd/sys/windows/os_str.rs @@ -128,6 +128,7 @@ impl Buf { } impl Slice { + #[inline] pub fn from_str(s: &str) -> &Slice { unsafe { mem::transmute(Wtf8::from_str(s)) } } diff --git a/src/libstd/sys_common/os_str_bytes.rs b/src/libstd/sys_common/os_str_bytes.rs index a2608ad4000d4..eb8a881ec8881 100644 --- a/src/libstd/sys_common/os_str_bytes.rs +++ b/src/libstd/sys_common/os_str_bytes.rs @@ -139,10 +139,12 @@ impl Buf { } impl Slice { + #[inline] fn from_u8_slice(s: &[u8]) -> &Slice { unsafe { mem::transmute(s) } } + #[inline] pub fn from_str(s: &str) -> &Slice { Slice::from_u8_slice(s.as_bytes()) }