Skip to content

Commit b19c14a

Browse files
committed
Auto merge of #242 - quininer:patch-2, r=Amanieu
always inline `ScopeGuard::drop` I accidentally discovered that some minor changes in a production project will cause a lot of size increase and some performance regression. After comparison, I found a lot of `ScopeGuard::drop` symbols appeared in the poorer version. I suspect this is because the compiler missed some inline. for `ScopeGuard`, it should always be beneficial to inline it.
2 parents de77272 + 1ae6dc0 commit b19c14a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/scopeguard.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ where
99
value: T,
1010
}
1111

12-
#[cfg_attr(feature = "inline-more", inline)]
12+
#[inline]
1313
pub fn guard<T, F>(value: T, dropfn: F) -> ScopeGuard<T, F>
1414
where
1515
F: FnMut(&mut T),
@@ -22,7 +22,7 @@ where
2222
F: FnMut(&mut T),
2323
{
2424
type Target = T;
25-
#[cfg_attr(feature = "inline-more", inline)]
25+
#[inline]
2626
fn deref(&self) -> &T {
2727
&self.value
2828
}
@@ -32,7 +32,7 @@ impl<T, F> DerefMut for ScopeGuard<T, F>
3232
where
3333
F: FnMut(&mut T),
3434
{
35-
#[cfg_attr(feature = "inline-more", inline)]
35+
#[inline]
3636
fn deref_mut(&mut self) -> &mut T {
3737
&mut self.value
3838
}
@@ -42,7 +42,7 @@ impl<T, F> Drop for ScopeGuard<T, F>
4242
where
4343
F: FnMut(&mut T),
4444
{
45-
#[cfg_attr(feature = "inline-more", inline)]
45+
#[inline]
4646
fn drop(&mut self) {
4747
(self.dropfn)(&mut self.value)
4848
}

0 commit comments

Comments
 (0)