Skip to content

Commit

Permalink
std: Inline some Termination-related methods
Browse files Browse the repository at this point in the history
These were showing up in tests and in binaries but are trivially optimize-able
away, so add `#[inline]` attributes so LLVM has an opportunity to optimize them
out.
  • Loading branch information
alexcrichton committed Apr 5, 2018
1 parent 56714ac commit 323f808
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,7 @@ pub trait Termination {

#[unstable(feature = "termination_trait_lib", issue = "43301")]
impl Termination for () {
#[inline]
fn report(self) -> i32 { ExitCode::SUCCESS.report() }
}

Expand Down Expand Up @@ -1481,6 +1482,7 @@ impl<E: fmt::Debug> Termination for Result<!, E> {

#[unstable(feature = "termination_trait_lib", issue = "43301")]
impl Termination for ExitCode {
#[inline]
fn report(self) -> i32 {
self.0.as_i32()
}
Expand Down
1 change: 1 addition & 0 deletions src/libstd/sys/unix/process/process_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ impl ExitCode {
pub const SUCCESS: ExitCode = ExitCode(EXIT_SUCCESS as _);
pub const FAILURE: ExitCode = ExitCode(EXIT_FAILURE as _);

#[inline]
pub fn as_i32(&self) -> i32 {
self.0 as i32
}
Expand Down
1 change: 1 addition & 0 deletions src/libstd/sys/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ impl ExitCode {
pub const SUCCESS: ExitCode = ExitCode(EXIT_SUCCESS as _);
pub const FAILURE: ExitCode = ExitCode(EXIT_FAILURE as _);

#[inline]
pub fn as_i32(&self) -> i32 {
self.0 as i32
}
Expand Down

0 comments on commit 323f808

Please sign in to comment.