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:
parent
5c9636975c
commit
7ba5f166b4
1 changed files with 2 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue