Mark the {min,max}_value functions on integers #[inline].

These compile down to `mov $CONSTANT, register; ret`, but the lack of
`#[inline]` meant they have a full `call ...` when used from external
crates.
This commit is contained in:
Huon Wilson 2015-05-01 08:56:13 +10:00
parent 5c9636975c
commit 7ba5f166b4

View file

@ -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
}