]> git.lizzy.rs Git - rust.git/commitdiff
Mark the {min,max}_value functions on integers #[inline].
authorHuon Wilson <dbau.pp+github@gmail.com>
Thu, 30 Apr 2015 22:56:13 +0000 (08:56 +1000)
committerHuon Wilson <dbau.pp+github@gmail.com>
Thu, 30 Apr 2015 23:15:10 +0000 (09:15 +1000)
These compile down to `mov $CONSTANT, register; ret`, but the lack of
`#[inline]` meant they have a full `call ...` when used from external
crates.

src/libcore/num/mod.rs

index 44d5333ce1f46bb582a11b97e2fe08718c52029e..f6c1960c30e1b667f00d7f744c45fd5e9e241a4b 100644 (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
         }