Skip to content

Commit f486b7c

Browse files
committed
Inline Duration constructors and accessors
These are all super small functions
1 parent 5ab11d7 commit f486b7c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libstd/time/duration.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ impl Duration {
5252
/// If the nanoseconds is greater than 1 billion (the number of nanoseconds
5353
/// in a second), then it will carry over into the seconds provided.
5454
#[stable(feature = "duration", since = "1.3.0")]
55+
#[inline]
5556
pub fn new(secs: u64, nanos: u32) -> Duration {
5657
let secs = secs + (nanos / NANOS_PER_SEC) as u64;
5758
let nanos = nanos % NANOS_PER_SEC;
@@ -60,12 +61,14 @@ impl Duration {
6061

6162
/// Creates a new `Duration` from the specified number of seconds.
6263
#[stable(feature = "duration", since = "1.3.0")]
64+
#[inline]
6365
pub fn from_secs(secs: u64) -> Duration {
6466
Duration { secs: secs, nanos: 0 }
6567
}
6668

6769
/// Creates a new `Duration` from the specified number of milliseconds.
6870
#[stable(feature = "duration", since = "1.3.0")]
71+
#[inline]
6972
pub fn from_millis(millis: u64) -> Duration {
7073
let secs = millis / MILLIS_PER_SEC;
7174
let nanos = ((millis % MILLIS_PER_SEC) as u32) * NANOS_PER_MILLI;
@@ -77,6 +80,7 @@ impl Duration {
7780
/// The extra precision represented by this duration is ignored (e.g. extra
7881
/// nanoseconds are not represented in the returned value).
7982
#[stable(feature = "duration", since = "1.3.0")]
83+
#[inline]
8084
pub fn as_secs(&self) -> u64 { self.secs }
8185

8286
/// Returns the nanosecond precision represented by this duration.
@@ -85,6 +89,7 @@ impl Duration {
8589
/// represented by nanoseconds. The returned number always represents a
8690
/// fractional portion of a second (e.g. it is less than one billion).
8791
#[stable(feature = "duration", since = "1.3.0")]
92+
#[inline]
8893
pub fn subsec_nanos(&self) -> u32 { self.nanos }
8994
}
9095

0 commit comments

Comments
 (0)