Skip to content

Commit

Permalink
Mark the {min,max}_value functions on integers #[inline].
Browse files Browse the repository at this point in the history
These compile down to `mov $CONSTANT, register; ret`, but the lack of
`#[inline]` meant they have a full `call ...` when used from external
crates.
  • Loading branch information
huonw committed Apr 30, 2015
1 parent 5c96369 commit 7ba5f16
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ macro_rules! int_impl {
$mul_with_overflow:path) => {
/// Returns the smallest value that can be represented by this integer type.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn min_value() -> $T {
(-1 as $T) << ($BITS - 1)
}

/// Returns the largest value that can be represented by this integer type.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn max_value() -> $T {
let min = $T::min_value(); !min
}
Expand Down

0 comments on commit 7ba5f16

Please sign in to comment.