Skip to content

Commit

Permalink
Rollup merge of rust-lang#53217 - strake:inline, r=nagisa
Browse files Browse the repository at this point in the history
inline some short functions

I found these were outline in binaries i link. I think they ought to be inline, considering their size.
  • Loading branch information
kennytm committed Aug 9, 2018
2 parents db74946 + b78201a commit 410f63d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
/// assert_eq!(2, 2.max(2));
/// ```
#[stable(feature = "ord_max_min", since = "1.21.0")]
#[inline]
fn max(self, other: Self) -> Self
where Self: Sized {
if other >= self { other } else { self }
Expand All @@ -485,6 +486,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
/// assert_eq!(2, 2.min(2));
/// ```
#[stable(feature = "ord_max_min", since = "1.21.0")]
#[inline]
fn min(self, other: Self) -> Self
where Self: Sized {
if self <= other { self } else { other }
Expand Down
4 changes: 4 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ unsafe impl<'a, A> TrustedLen for Iter<'a, A> {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, A> Clone for Iter<'a, A> {
#[inline]
fn clone(&self) -> Iter<'a, A> {
Iter { inner: self.inner.clone() }
}
Expand Down Expand Up @@ -1307,14 +1308,17 @@ impl<T> ops::Try for Option<T> {
type Ok = T;
type Error = NoneError;

#[inline]
fn into_result(self) -> Result<T, NoneError> {
self.ok_or(NoneError)
}

#[inline]
fn from_ok(v: T) -> Self {
Some(v)
}

#[inline]
fn from_error(_: NoneError) -> Self {
None
}
Expand Down
4 changes: 4 additions & 0 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ unsafe impl<'a, A> TrustedLen for Iter<'a, A> {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for Iter<'a, T> {
#[inline]
fn clone(&self) -> Iter<'a, T> { Iter { inner: self.inner } }
}

Expand Down Expand Up @@ -1235,14 +1236,17 @@ impl<T,E> ops::Try for Result<T, E> {
type Ok = T;
type Error = E;

#[inline]
fn into_result(self) -> Self {
self
}

#[inline]
fn from_ok(v: T) -> Self {
Ok(v)
}

#[inline]
fn from_error(v: E) -> Self {
Err(v)
}
Expand Down

0 comments on commit 410f63d

Please sign in to comment.