Skip to content

Commit df9cc27

Browse files
committed
Mark the {min,max}_value functions in 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.
1 parent 5c96369 commit df9cc27

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/libcore/num/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,14 @@ macro_rules! int_impl {
113113
$mul_with_overflow:path) => {
114114
/// Returns the smallest value that can be represented by this integer type.
115115
#[stable(feature = "rust1", since = "1.0.0")]
116+
#[inline]
116117
pub fn min_value() -> $T {
117118
(-1 as $T) << ($BITS - 1)
118119
}
119120

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

0 commit comments

Comments
 (0)