Skip to content

Commit b38c118

Browse files
committed
Add #[inline] to most methods
1 parent f410951 commit b38c118

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+983
-5
lines changed

time-core/src/convert.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ macro_rules! impl_per {
6666
" - `", stringify!($t), "::per(", stringify!($larger), ")` (returns `",
6767
stringify!($default_output), "`)"
6868
)])+
69+
#[inline]
6970
pub const fn per<T>(_larger: T) -> <T as DefaultOutput<Self>>::Output
7071
where
7172
T: MultipleOf<Self, T::Output> + DefaultOutput<Self> + Copy,
@@ -83,6 +84,7 @@ macro_rules! impl_per {
8384
" - `", stringify!($t), "::per(", stringify!($larger), ")` (returns ",
8485
stringify_outputs!($($int_output),+ , $($float_output),+), ")"
8586
)])+
87+
#[inline]
8688
pub const fn per_t<Output>(larger: impl MultipleOf<Self, Output> + Copy) -> Output {
8789
multiple_of_value(larger)
8890
}

time-core/src/util.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::hint;
1313
/// assert!(!is_leap_year(2005));
1414
/// assert!(!is_leap_year(2100));
1515
/// ```
16+
#[inline]
1617
pub const fn is_leap_year(year: i32) -> bool {
1718
let d = if year % 100 == 0 { 15 } else { 3 };
1819
year & d == 0
@@ -30,6 +31,7 @@ pub const fn is_leap_year(year: i32) -> bool {
3031
/// assert_eq!(days_in_year(2005), 365);
3132
/// assert_eq!(days_in_year(2100), 365);
3233
/// ```
34+
#[inline]
3335
pub const fn days_in_year(year: i32) -> u16 {
3436
if is_leap_year(year) {
3537
366
@@ -47,6 +49,7 @@ pub const fn days_in_year(year: i32) -> u16 {
4749
/// assert_eq!(weeks_in_year(2019), 52);
4850
/// assert_eq!(weeks_in_year(2020), 53);
4951
/// ```
52+
#[inline]
5053
pub const fn weeks_in_year(year: i32) -> u8 {
5154
match year % 400 {
5255
-396 | -391 | -385 | -380 | -374 | -368 | -363 | -357 | -352 | -346 | -340 | -335
@@ -72,6 +75,7 @@ pub const fn weeks_in_year(year: i32) -> u8 {
7275
/// ```
7376
///
7477
/// Note: This function is not exposed by the `time` crate. It is an implementation detail.
78+
#[inline]
7579
pub const fn days_in_month(month: u8, year: i32) -> u8 {
7680
debug_assert!(month >= 1);
7781
debug_assert!(month <= 12);

0 commit comments

Comments
 (0)