Skip to content

Commit acc3ab4

Browse files
committed
Make all {Mutex, Condvar, RwLock}::new #[inline].
1 parent e70c60d commit acc3ab4

File tree

15 files changed

+21
-4
lines changed

15 files changed

+21
-4
lines changed

library/std/src/sync/condvar.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ impl Condvar {
123123
/// ```
124124
#[stable(feature = "rust1", since = "1.0.0")]
125125
#[must_use]
126-
pub fn new() -> Condvar {
126+
#[inline]
127+
pub const fn new() -> Condvar {
127128
Condvar { inner: sys::Condvar::new() }
128129
}
129130

library/std/src/sync/mutex.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ impl<T> Mutex<T> {
214214
/// let mutex = Mutex::new(0);
215215
/// ```
216216
#[stable(feature = "rust1", since = "1.0.0")]
217-
pub fn new(t: T) -> Mutex<T> {
217+
#[inline]
218+
pub const fn new(t: T) -> Mutex<T> {
218219
Mutex {
219220
inner: sys::MovableMutex::new(),
220221
poison: poison::Flag::new(),

library/std/src/sync/poison.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub struct Flag {
1919
// all cases.
2020

2121
impl Flag {
22+
#[inline]
2223
pub const fn new() -> Flag {
2324
Flag { failed: AtomicBool::new(false) }
2425
}

library/std/src/sync/rwlock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ impl<T> RwLock<T> {
146146
/// let lock = RwLock::new(5);
147147
/// ```
148148
#[stable(feature = "rust1", since = "1.0.0")]
149-
pub fn new(t: T) -> RwLock<T> {
149+
#[inline]
150+
pub const fn new(t: T) -> RwLock<T> {
150151
RwLock {
151152
inner: sys::MovableRwLock::new(),
152153
poison: poison::Flag::new(),

library/std/src/sys/itron/mutex.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ fn new_mtx() -> Result<abi::ID, ItronError> {
2626
}
2727

2828
impl Mutex {
29+
#[inline]
2930
pub const fn new() -> Mutex {
3031
Mutex { mtx: SpinIdOnceCell::new() }
3132
}

library/std/src/sys/solid/rwlock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ fn new_rwl() -> Result<abi::ID, ItronError> {
2323
}
2424

2525
impl RwLock {
26+
#[inline]
2627
pub const fn new() -> RwLock {
2728
RwLock { rwl: SpinIdOnceCell::new() }
2829
}

library/std/src/sys/unsupported/locks/condvar.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub struct Condvar {}
66
pub type MovableCondvar = Condvar;
77

88
impl Condvar {
9+
#[inline]
910
pub const fn new() -> Condvar {
1011
Condvar {}
1112
}

library/std/src/sys/unsupported/locks/mutex.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ unsafe impl Send for Mutex {}
1111
unsafe impl Sync for Mutex {} // no threads on this platform
1212

1313
impl Mutex {
14+
#[inline]
1415
pub const fn new() -> Mutex {
1516
Mutex { locked: Cell::new(false) }
1617
}

library/std/src/sys/unsupported/locks/rwlock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ unsafe impl Send for RwLock {}
1111
unsafe impl Sync for RwLock {} // no threads on this platform
1212

1313
impl RwLock {
14+
#[inline]
1415
pub const fn new() -> RwLock {
1516
RwLock { mode: Cell::new(0) }
1617
}

library/std/src/sys/windows/locks/condvar.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ unsafe impl Send for Condvar {}
1414
unsafe impl Sync for Condvar {}
1515

1616
impl Condvar {
17+
#[inline]
1718
pub const fn new() -> Condvar {
1819
Condvar { inner: UnsafeCell::new(c::CONDITION_VARIABLE_INIT) }
1920
}

0 commit comments

Comments
 (0)